- Home /
Child transforms and rotates without parent
I'm creating a subway surfer style game where the character is constantly moving forward. I have a run in place animation from mixamo.com so that the character looks like it is running when it is moving forward. Recently, I added a roll animation that plays when the "s" key is pressed that plays and then after it is done, resumes the running animation. However, when I trigger the roll animation too many times the character starts to rotate towards the left and transform to the left. The thing is the running character is attached to a normal cylinder object that has all the code on it. The running character transforms and rotates, but the parent (cylinder) keeps going along its path. I was thinking that a possible fix to the rotation and transforming is keeping the character in line with the parent. If there is any other solution, I would be glad to hear them too. Thanks!
Answer by Drislak · Apr 01, 2020 at 10:00 AM
I see a few things you could try @erwang_unity
If what you want is to reposition the child to the parent location, you can just put its transform equal to the parent transform after each animation.
If the issue is the character moving slightly to the side, you might want to put some Constraints on your Rigidbody (e.g. Freeze Position x and z will lock them to not move with gravity).
Reposition all your code to the parent, the setup of my character is Player (parent) > Model (child) with the Model only containing an Animator (which is called in the Player).
Hope this helps! If you know anything about UI and/or dragging please look at my question: https://answers.unity.com/questions/1713272/detect-ui-under-mouse-during-drag.html
Your answer
Follow this Question
Related Questions
NPC walk animation 3 Answers
How do I rotate my parent object without rotating the child object? 0 Answers
2D eyes on 3D character? 2 Answers
Animating different Weapons 2 Answers