- Home /
Why I can't rotate gameobject around z-axis correctly (2D)
Hi all,
I'm making a 2D game. I have some problems with rotation gameobject around z axis. So, I try to run this code:
public void TankRotate(GameObject go){
if (countRotate > 0) {
go.transform.Rotate (0,0, 2);
countRotate -= 2;
} else {
countRotate += 2;
go.transform.Rotate (0,0, -2);
}
if (countRotate == 0) {
needToRotate = false;
}
}
but when computer automatically run this function for computer's objects, it works correctly, but when I rotate my gameobject using special keys such as "W", "A", "S", "D" or using arrows this function works wrong. So, when I change z-value on rotation and check it, it's correct, but when function update() starts again, the z-value is other. For example: I changed the z-value from 170 to 168 but got 168,1705. This problem appeared when I updated unity version from 4,3 to 5,5. Could you help me please?
Your answer
![](https://koobas.hobune.stream/wayback/20220612104732im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Issue with Android SDK and JDK for Unity 5.4.x 1 Answer
Main Camera for a 2d-Game is blue! The scene and all the objects are not shown! 1 Answer
Mobile Development screen resolution and aspect ration 1 Answer
How can I spawn different GameObjects using IEnumerator? 1 Answer
A* pathfinding for dynamic obstacles and player made blockages? 0 Answers