- Home /
How can I rotate my gameobject around z-axis correctly?
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?
Comment