Joint two carriages with hingejoint in runtime
Hello. I have 2 carriages on scene. How to join them when they are colliding?
Let's assume my carriage consists from 3 cubes, the main cube between link cubes.
Here is my script, which detects collisions with other carriage (actually link cube of other carriage).
void OnCollisionEnter (Collision other) { if(other.gameObject.tag == LINKER_TAG && linkHingeJoint==null) { linkHingeJoint = gameObject.AddComponent (); linkHingeJoint.axis = jointAxis; linkHingeJoint.anchor = jointAnchor; linkHingeJoint.connectedBody = other.gameObject.GetComponent (); } }
The problem is, when these two link cubes are colided, my carriages burst like explosion. I don't know why such situation happens. When i do it from unity-editor, all works good, but i need link carriages in runtime.
Your answer
Follow this Question
Related Questions
Charachter Controller and collisions (Door) help 1 Answer
Flail like weapon / Hinge Joint 0 Answers
Help with coding crane 0 Answers