- Home /
Question by
frugoli7 · Oct 01, 2015 at 06:12 PM ·
quaternionvelocityspace shooterquaternionstilt
Fixed tilt rotation on speed up problem
Hello everyone, i'm working on a game based on Space Shooter Tutorial. My problem is related to the tilt and speed of the spaceship. I wrote a code that allows me to increase the speed of the spaceship when it touches an object. The problem is that besides the speed also changes the angle of rotation of the spaceship when steering. How can i set the rotation fixed? This is the code of the rotation:
GetComponent<Rigidbody>().rotation = Quaternion.Euler (0.0f, 0.0f, GetComponent<Rigidbody>().velocity.x * -tilt);
This is the speed:
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
GetComponent<Rigidbody>().velocity = movement * speed;
If i set a number instead of GetComponent().velocity.x * -tilt the ship is always rotated and not only if it's moving! How can i do this? I would prefer not to add other operations but have a code that you simply make the rotation independent of the speed.
Thank you!
Comment