Hello, I’m currently making a space type movement system.
My current movement script so far is stated below.
if (Input.GetKey(KeyCode.W))
rigidbody.AddRelativeForce (Vector3.forward * speed);
if (Input.GetKey(KeyCode.S))
rigidbody.AddRelativeForce (Vector3.back * speed);
if (Input.GetKey(KeyCode.D))
rigidbody.AddRelativeForce (Vector3.right * speed);
if (Input.GetKey(KeyCode.A))
rigidbody.AddRelativeForce (Vector3.left * speed);
if (Input.GetKey(KeyCode.Space))
rigidbody.AddRelativeForce (Vector3.up * speed);
if (Input.GetKey(KeyCode.LeftControl))
rigidbody.AddRelativeForce (Vector3.down * speed);
rigidbody.AddRelativeTorque ((Input.GetAxis("Vertical"))*turnSpeed,0,0);
rigidbody.AddRelativeTorque (0,(Input.GetAxis("Horizontal"))*turnSpeed,0);
So far this works perfectly for what I want it for. Now i’m also trying to make it so when a player lets go of the movement the ship auto stops.
For example.
If the ship is moving foward, engage front thrusters to push it back.
I have looked all over and can not find a way to detect if Vector3.foward speed is bigger than 0.
Can anybody help me with this?
Thanks.