I have GameObject with Collider & Rigidbody attached to it,
with 2 child GameObjects with WheelCollider attached. This child gameObject is a prefab.
This works good.
Now at runTime I want to add more prefabs to it. So I call:
GameObject go = Instantiate(prefab) as GameObject;
go.parent = rigidbodyGameObjectTransform;
But "Instantiate" will give me error even before I get chance to call "go.parent" :
WheelCollider requires an attached Rigidbody to function.
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
↧