- Home /
Character controller moves slow when an object its parented
I have an object (a sphere) that when i hit it, the object "parents" itself to my character controller, in other words it becomes a child of the character controller. The problem i am having is that moving around becomes very difficult when this object is attached. The character controller will sometimes not move forward at all, or move slightly diagonally and very slowly, or move normal in some directions but not others. Once the object is unparented (with a mouse click) all is back to normal.
Now the sphere does have a rigidbody and i have been told to never parent an object to another if both have rigidbodies but as far as i can see the character controller does not have one. Also when the object is being parented i am making it kinematic anyway which i also thought would not cause any problems.
If anyone needs code then i can provide.
Thanks in advance.
Answer by Owen-Reynolds · Mar 06, 2014 at 10:47 PM
Character controllers work funny when other colliders are childed to them. My longer explanation near the bottom, this person has a weapon child: http://answers.unity3d.com/questions/341530/character-movement-distorted-when-holding-weapon.html
Now, a rigidbody moving with physics loves children. You can combine a few cubes and spheres (as you wrote, only the top object gets the rigid body) and it will gladly act as a single solid object.
This is brilliant thanks. I will start experimenting soon and seeing if i can restore some normal movement. Would you suggest perhaps turning the sphere collider on the child object off when parented (then to pop it back on when it is "released")?
The exact hack to make it sort of work depends. Suddenly turning on a collider might have it appear in a wall, which could make it blast away or fall through. It it isn't touching the character capsule, movement will be fine, but I think it will won't count as the player, so could be pushed through a wall anyway. Some people have had luck with Springs. Or switch to physics-based movement (huge pain to switch.) Or always put it on top of the player (so it never causes a problem) ... .
Thank you for the options. I will have a play around with them and see what suits. I will also look into springs as i do not know what they are.