Unknown error
So i decided to upgrade my unity a few days ago (from 5.0-5.3) when it got within the program stuff starting getting weird i couldn't import images, I couldn't change settings and the game i made's camera was way off and was being stupid, So i decide to uninstall it and reinstall 5.0, but when i opened it i keep getting this error and have no idea what it means, and on all my gameobjects that have scripts saying there's errors and need fixing, in the console i have this error error CS1061: Type UnityEngine.SpringJoint2D' does not contain a definition for
enableCollision' and no extension method enableCollision' of type
UnityEngine.SpringJoint2D' could be found (are you missing a using directive or an assembly reference?) the script i have this error for is this using UnityEngine; using System.Collections;
public class MouseManager : MonoBehaviour {
public bool useSpring = false;
public LineRenderer dragLine;
Rigidbody2D grabbedObject = null;
SpringJoint2D springJoint = null;
float velocityRatio = 4f; // If we aren't using a spring
void Update() {
if( Input.GetMouseButtonDown(0) ) {
// We clicked, but on what?
Vector3 mouseWorldPos3D = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector2 mousePos2D = new Vector2(mouseWorldPos3D.x, mouseWorldPos3D.y);
Vector2 dir = Vector2.zero;
RaycastHit2D hit = Physics2D.Raycast(mousePos2D, dir);
if(hit.collider!=null) {
// We clicked on SOMETHING that has a collider
if(hit.collider.GetComponent<Rigidbody2D>() != null) {
grabbedObject = hit.collider.GetComponent<Rigidbody2D>();
if(useSpring) {
springJoint = grabbedObject.gameObject.AddComponent<SpringJoint2D>();
// Set the anchor to the spot on the object that we clicked.
Vector3 localHitPoint = grabbedObject.transform.InverseTransformPoint(hit.point);
springJoint.anchor = localHitPoint;
springJoint.connectedAnchor = mouseWorldPos3D;
springJoint.distance = 0.25f;
springJoint.dampingRatio = 1;
springJoint.frequency = 5;
// Enable this if you want to collide with objects still (and you probably do)
// This will also WAKE UP the spring.
springJoint.enableCollision = true;
// This will also WAKE UP the spring, even if it's a totally
// redundant line because the connectedBody should already be null
springJoint.connectedBody = null;
}
else {
// We're using velocity instead
grabbedObject.gravityScale=0;
}
dragLine.enabled = true;
}
}
}
if( Input.GetMouseButtonUp(0) && grabbedObject!=null ) {
if(useSpring) {
Destroy(springJoint);
springJoint = null;
}
else {
grabbedObject.gravityScale=1;
}
grabbedObject = null;
dragLine.enabled = false;
}
}
void FixedUpdate () {
if(grabbedObject != null) {
Vector2 mouseWorldPos2D = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if(useSpring) {
springJoint.connectedAnchor = mouseWorldPos2D;
}
else {
grabbedObject.velocity = (mouseWorldPos2D - grabbedObject.position) * velocityRatio;
}
}
}
void LateUpdate() {
if(grabbedObject != null) {
if(useSpring) {
Vector3 worldAnchor = grabbedObject.transform.TransformPoint(springJoint.anchor);
dragLine.SetPosition(0, new Vector3(worldAnchor.x, worldAnchor.y, -1));
dragLine.SetPosition(1, new Vector3(springJoint.connectedAnchor.x, springJoint.connectedAnchor.y, -1));
}
else {
Vector3 mouseWorldPos3D = Camera.main.ScreenToWorldPoint(Input.mousePosition);
dragLine.SetPosition(0, new Vector3(grabbedObject.position.x, grabbedObject.position.y, -1));
dragLine.SetPosition(1, new Vector3(mouseWorldPos3D.x, mouseWorldPos3D.y, -1));
}
}
}
}
Please help
Your answer
Follow this Question
Related Questions
How to fix a compiler error? 2 Answers
An instance of type 'UnityEngine.Behaviour' is required to access non static member 'enabled'. 0 Answers
Unable to get VRTK 3.2.1 working in Unity 5.6,Unable to get VRTK 3.2.1 to run in Unity 5.6 0 Answers
Hundreds off errors n console upon starting Unity 2018.3.9f1 related to "has no meta file" 0 Answers
How do I fix this Text Mesh Pro Error? 0 Answers