Adding 1 frame of force

How can I add force to a rigidbody for 1 frame, after which the force slowly dies down? It’s for a dash related script. I’m using 2D if that matters. Any help is appreciated.

You’re gonna need to use Rigidbody2D.AddForce . And since you want to apply force at an instant you will have to use ForceMode2D.Impulse as the mode. But without a force acting opposite to the direction of the the force you applied, your character will never stop moving. So you will need to change the value of Linear Drag in your character’s rigidbody2D component from 0 to 1 (you might want to experiment with the values to get the desired result). With this setup you will get what you’re looking for.Hope it helps.

I believe what you’re looking for is the RigidBody.AddForce method.

(Unity - Scripting API: Rigidbody.AddForce)

Then you will also want to look at the Force Modes that you can apply. You’re probably looking for either Impulse or VelocityChange. Both will be single frame, but one will look at the mass, the other will ignore it. See how that goes.

(Unity - Scripting API: ForceMode)