1
votes

I am currently using Unity 3D to create a 3rd person game. But I am having an issue with trying to parent to the closest child transform of an object:

whenever the player comes into contact with a specific tagged gameObject, the collided game object becomes a child of the player. However I want it to child itself to the closest bone it collided at. So far i have set up a for loop that searches for the closest local position to the collided object and found the Vector3 of the closest bone.

But now I want it to child itself to the transform with that local Vector3. If anyone has any advice on how to do this then this would be greatly appreciated. If you would like to see example code, then just say.

Thanks

1

1 Answers

1
votes

One solution is to attach colliders to all all bones and then you can easily set up the parent child connection. In order to create all the colliders yo can use the ragdoll wizard. I used this successfully for a similar problem in my project and even on iOS the additional colliders (IsTrigger = true) don't decrease the performance.