V
V
Vadim)))2021-12-08 00:11:51
Unity
Vadim))), 2021-12-08 00:11:51

How to connect all child objects with a Fixed Joint component?

I have a Car object that has n Detail children. How can I add a Fixed Joint to each of these objects, which will be connected to the rest?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Farawa, 2021-12-08
@Farawa

private void JoinChildrens()
{
var rig = GetComponent();
for(int i = 0; i < transform.childCount; i++)
{
var fix = transform.GetChild(i).gameObject.AddComponent();
fix.connectedBody = rig;
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question