- Home /
Answer by hrishihawk · Mar 12, 2018 at 05:38 AM
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.
Answer by Nerull22 · Mar 12, 2018 at 12:30 AM
I believe what you're looking for is the RigidBody.AddForce method.
(https://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html)
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.