- Home /
GameObject rotation not working
Hello, right now I am making a 2D platformer game. My character is split into a head, torso (two hands attached to it), and two feet that are separately attached. This character has an Idle animation (another important note: I am using unity for animations). The idle animation does not change the rotation of the character's left arm nor right arm, however I also added a punch animation (3 animations) that changes the rotation of the left arm but not right arm. The rotation of both arms before the game starts is (0, 0, 0). I wanted to change both to (0, 0, 90) as soon as the game starts. I did it with the code:
left_arm.localRotation = Quaternion.Euler(0, 0, 90);
right_arm.localRotation = Quaternion.Euler(0, 0, 90);
When I start the game, the right arm does change its rotation on the z axis is 90. However, the left arm stays at rotation.z = 0. I disabled the animator and ran the game, then both arm has the right rotation on z axis. I know that the animator and the animation that uses the rotation.z of left arm is at fault here. However, I don't know how to fix this, since Idle animation is the default animation, and it does not use the rotation of the left arm.
For additional information: the arms are both attached to a gameobject called pivot_arm.
I have been stuck for quite a while, thanks in advance for helping.
Did you check if the game Object is connected to the script?
Answer by BingBangBong457 · Apr 14, 2021 at 08:10 PM
The only way that has worked for me is make the sprite start out with a z rotation of 90 degrees. But I guess that isn't really useful since its in a fixed rotation afterwards (and by that I mean you can't edit in the code).
Your answer
Follow this Question
Related Questions
Importing MotionBuilder Animations to Unity 5. 1 Answer
Can I make animations snap to a frame? 1 Answer
How would I switch between 2 animation states connected to 1 state under input? 0 Answers
Character animation modeling 2 Answers
The parts of my character disappear when i use the animation 0 Answers