- Home /
When I set an object to be the child of another object, the child object does not anchor to the parent's position for about 25 seconds
Basically, I have it set up so when the player collides with a certain object, the object becomes the player object's child and the object is supposed to follow the player around due to the child object's position being anchored to the player's. However, what actually happens is, the object does, in fact, become the player's child, and the object's origin position even becomes the player's position, but it doesn't follow the player. The player moves and the object is left behind, changing the object's position values so it stays in the same spot. After around 25 seconds, the object snaps to the correct position and follows the player like normal. It's very strange, and I don't know why this is happening. Has anyone else experienced this? Does anyone know how to fix it?
I'm sorry if my explanation isn't very good... I'm very confused.
Answer by jdean300 · Feb 07, 2017 at 08:34 AM
Just a hunch here - are they both rigidbodies? If so, you are either going to need to destroy/deactivate the child's rigidbody or look into using joints. Rigidbodies take control of the GameObject they are attached to, and so the child's rigidbody is taking over and controlling it's location. The delay is probably just an artifact of the rigidbodies conflicting in strange ways.
Yeah, that must be it. Could I just deactivate the child's Rigidbody for a second and reactivate it? Or would it have to be deactivated for as long as it's the child of the player?
I should mention though that there isn't much of a reason to have the child rigidbody active. The childs colliders should automatically start working for the parent's rigidbody. If you do need them both active for some reason: joints. When using joints the objects aren't really in a parent/child relationship.
I want the rotational velocity of the child object to be maintained as it becomes the child, but if that's not possible it's okay. I'll look into joints.