- Home /
Question by
thedodgeruk · Nov 25, 2012 at 01:44 PM ·
assign
assign wheel collider through script
i have an object called wheelColliderFl which contains a wheel collider, i know i can drag and drop this object onto a script , but this is a bit messy for each time.
is there a way so that i can get the main game object to do , find("wheelColliderFl );
i tryed this but it not seam to work
Comment
Answer by CostelloNicho · Nov 25, 2012 at 08:30 PM
I hope this answers your question: (written for C#, since there was no language specification)
GameObject _temp;
_temp = GameObject.Find("wheelColliderFl");
_temp.AddComponent("YourScriptHere");
If you are just trying to gather these objects inside your script all you need to use is this line:
GameObject WheelCollider1 = GameObject.Find("wheelCollider1");
Now you can Assign any of those objects wheel colliders:
WheelCollider1.AddComponent<WheelCollider>();
(It will require a rigid body)