Reputation: 45
The task is to make a bicycle. When a stone is thrown to the bicycle, the bicycle should be scattered in different parts.
I've made the bicycle with bicycle frame and wheels and join them using Wheel Joint. I need to know how can I break these joints using Script or anything?
Please help...
Upvotes: 1
Views: 2986
Reputation: 45
I found a solution. So, I am sharing that may help others.
I disabled the component of WheelJoint in script by using this line of code.
GetComponent<"WheelJoint2D"> ().enabled = false;//This line will disable the component. If you want to enable it use this. GetComponentInChildren<"WheelJoint2D"> ().enabled = true;
*Use the name of Component without Quotes("") .
Upvotes: 0
Reputation: 1222
You can set Joint.breakForce to a value and then apply a force greater then this force to break it. if Joint.breakForce = Mathf.Infinity it will make joint unbreakable.
Upvotes: 2