How to use rigidbody.AddForce in a single frame.

Hi guys, I’m making a gun drop away from the player but when I apply the rigidbody.Addforce on it, it doesnt stop moving, I have everything working fine, the possible solution is to make the “AddForce” works like when we call it on “void Start () {}”, I just dont understand why it still updating the command even if I close it in a simple “If”

I’m using “rigidbody.AddForce (transform.forward * 20);”

I already tried to use a coroutine to fix my problem:

public IEnumerator ThrowWeapon()
		Weapon.rigidbody.AddForce  (transform.forward * 20f);
		yield return new WaitForSeconds(0.25f);
		Weapon.rigidbody.AddForce  (transform.forward * -20f);

this works almost fine, the only problem is that the object never sleep, and I dont want to waste memory

I feel like I’m forgetting something, maybe I’m just tired.
if I find a solution I post here, Peace off.


I had to make a condition to the object so when its touching the ground I call rigidbody.velocity =, it was effective, and the transform of the object in the inspector stopped as I wanted, I didnt use the rigidbody.AddForce in a single frame but at least I could solve my main problem.

Is the object even coming to a rest? (lying still)

Did you apply a PhysicsMaterial to the gun that has friction? (makes it stop by itself)

If its just one gun forget about the performance

If you want the rigidbody to “STOP” call rigidbody.velocity = on it.

You could also use an Impulse force instead of a constant one (if I understand what you are trying to do). You can add “ForceMode.Impulse” to your line :

     Weapon.rigidbody.AddForce  (transform.forward * 20f, ForceMode.Impulse);

If you do so, I think the two other lines would be useless.