I have a space ship which gets it movement from addRelativeForce when the verticle axis is pressed. The thing I’d like it to do is slow or stop the ship when the user stops pressing the move button. Is there a way to apply a force in the opposite direction until a certain magnitude is achieved? Also there is no gravity in the scene.
function FixedUpdate(){
var moveShip = Input.GetAxis("Vertical");
var movement = new Vector3(0,moveShip + boost,0);
var currSpeed = rigidbody.velocity.magnitude;
rigidbody.AddRelativeForce(movement * speed * Time.deltaTime);
if(Input.GetKey("space") && Input.GetAxis("Vertical")){
boost = 5;
}else{
boost = 0;
}
}
Thanks
Sorry for the late response. Setting the drag works perfectly. Thanks
– ThumbStorm