سؤال

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.

هل كانت مفيدة؟

المحلول

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).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top