- Home /
Accessing both wheelJoint2d's in gameobjects..?
I have an orthographic car which is made from a rigidbody2d with wheeljoint2d's and wheels. The car works fine, but I'm trying to snap the wheeljoints off when the car hits ground hard enough.. the following code works for the front wheel, but how would I access the other wheeljoint2d?
function OnCollisionEnter2D(collision : Collision2D)
{
if (collision.relativeVelocity.magnitude > hitTolerance)
{
GetComponent(WheelJoint2D).enabled = false;
}
}
answers.png
(44.6 kB)
Comment
Answer by Cheef · Nov 09, 2014 at 01:39 PM
Well, figured it out. At least it works for me, for now..
var wheelJoints : WheelJoint2D[];
for (var joint : WheelJoint2D in wheelJoints)
{
joint.enabled = false;
}
Your answer
Follow this Question
Related Questions
How to plot a 2d dotted line 0 Answers
Gameobject not moving unless starting at 0 transform 0 Answers
2D snake game stop sprite from leaving screen 1 Answer
Pixels Warped/Distorted - Nothing Has Worked So Far 2 Answers
Display "Typewriter Text Effect" when a bool is set to true in another script. 0 Answers