Hi Guys
I have an rigid-body object to which I have added force in a particular direction. I want to be able to bring this object to a stop when I press a certain key.
void object_movement(){
if(Input.GetKey(KeyCode.Space)){
jump = jump + setjumpheight;
object.rigidbody.AddForce(0.0f,jump,0.0f);
}
else{
if(Input.GetKey(“up”)){
speed = speed + incrementspeedby;
object.rigidbody.AddForce(0.0f,0.0f,speed);
}
}
if(Input.GetKey(“down”)){
speed1 = decrementspeedby - speed;
object.rigidbody.AddForce(0.0f,0.0f,speed1);
}
}
this is the function that I am calling in my
Void Updated() function.
the current result is the on pressing the down arrow key the objects starts moving in the opposite direction. Instead I want the object to come to a stop.