- Home /
Fixed joint doesn't work after gameobject disabled and enabled
I took 2 gameobjects and added rigidbody to it.
Added fixedjoint to one gameobject and put connected body another gameobject.
Both game object move together if I add force to one gameobject.
I disabled connected body gameobject for a moment and then enabled it. 5.gameobjects are not behaving as per the property of fixed joint. They move separately like there is no joint.
Please help me with this problem
Answer by Relan42 · May 19 at 03:20 PM
You could try connecting the objects again through script after enabling them.
You'd have to make a Fixed Joint variable to access the fixed joint. like this.
public FixedJoint joint;
public GameObject body;
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
body.SetActive(!body.activeSelf);
joint.connectedBody = body.GetComponent<Rigidbody>();
}
}
Your answer
Follow this Question
Related Questions
If i disable a GameObject does all it's components get disabled also? 2 Answers
Collection of triggered colliders instead of OnTriggerStay? 0 Answers
enabled = true doesn't work the first time! 1 Answer
What is the best way to manage gameobjects in a scene to conserve memory? 0 Answers
C# - Disabled Script Still Runs! 1 Answer