Question by
respatyns · Jan 17, 2021 at 02:35 AM ·
rotationrotation axis
how to reset back the rotation
i'm trying to make a spaceship game, here code i used for movement for spaceship. and the case for now, i want to restore an spaceship to default value rotation (0,0,0) in any world.self how to do that. please help gaes, thanks before.
// Update is called once per frame void Update() {
if (Input.GetKey("d")) {
transform.position += Vector3.right * 5f * Time.deltaTime;
transform.Rotate(0, 0, 1, Space.Self);
}
if (Input.GetKey("a")) {
transform.position += Vector3.left * 5f * Time.deltaTime;
transform.Rotate(0, 0, -1, Space.Self);
}
if (Input.GetKey("w")) {
transform.position += Vector3.up * 5f * Time.deltaTime;
transform.Rotate(-1, 0, 0, Space.Self);
}
if (Input.GetKey("s")) {
transform.position += Vector3.down * 5f * Time.deltaTime;
transform.Rotate(1, 0, 0, Space.Self);
}
}
Comment
Your answer
Follow this Question
Related Questions
Camera self rotation script problem 1 Answer
Unity 2D rotation not smooth? 0 Answers
Rotating on other axis 1 Answer
Rotation on all axes 1 Answer
How to control rocket pathing with Quaternion.Slerp 1 Answer