- Home /
Rotating object and its speed
Hi,i have a ship with an addrelativeforce function that adds force to it when you press W,but when ship has already some velocity,when i rotate it with "transform.Rotate (Vector3.up, Time.deltaTime * 5);",the ship rotates but still has the velocity that it obtained with force before so it's like ship is swimming sideways.How can i fix this?
void Update () {
if (Input.GetKey (KeyCode.W)) {
rb.AddRelativeForce (Vector3.back * 10);
}
if (Input.GetKey (KeyCode.S)) {
rb.AddRelativeForce (Vector3.forward * 10);
}
if (Input.GetKey (KeyCode.A)) {
transform.Rotate (Vector3.down, Time.deltaTime * 5);
}if (Input.GetKey (KeyCode.D)) {
transform.Rotate (Vector3.up, Time.deltaTime * 5);
}
}
Comment
Your answer
Follow this Question
Related Questions
Imported model is rotated 90 degrees off of straight, can't use any transforms 1 Answer
relative velocity of rigidbody according to rotation... 1 Answer
Velocity bug with hinge joints forces in C# 0 Answers
Rotating the parent makes the whole object move 1 Answer
2d move object relative to its rotation/place random on specified line? 0 Answers