Hi guys,
I currently have a spaceship moving back and forward left and right and up and down. I am trying to make my character stop with the S key but it keeps moving I have tried to apply it but it seems not to be working please see my code anything I may be doing wrong. I have defined a variable called stopShip to 0 so when the S key is pressed there will be no value added to it so should come to a standstill any help would be great: ![]()
public class MoveCar : MonoBehaviour
{
public float moveSpeed = 2f;
public float turnSpeed = 2f;
public float stopShip = 0; // defined it 0 so there is no speed
void FixedUpdate()
{
if(Input.GetKey (KeyCode.F)) // forwards
{
rigidbody.AddForce(-moveSpeed,0,0);
}
else
if(Input.GetKey (KeyCode.S)) // make the character stop
{
rigidbody.AddForce(-stopShip,0,0);
}