Domanda

I'm building a Unity 2d game, when I add a HingeJoint component to a 3d gameobject like cube or sphere, I can access it through script like gameObject.hingerJoint.connectedBody = otherGameObject.rigibody;. But I can not access the HingeJoint2D component when I add it into a 2d gameObject.

È stato utile?

Soluzione

That just means they haven't added an explicit shorthand for it. You can still get it just as easily and quickly by using gameObject.GetComponent<HingeJoint2D>(). Using gameObject.hingeJoint is equivalent to using gameObject.GetComponent<HingeJoint>().

EDIT: Sorry, that was C#. In unityscript it's gameObject.GetComponent(HingeJoint2D).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top