# Calculating the force required to travel a specific distance

Discussion in 'Physics' started by Duskman0, Aug 2, 2020.

1. ### Duskman0

Joined:
Apr 28, 2019
Posts:
3
I'm trying to implement a dash mechanic in my 2D sidescroller game with physics based movement that allows you to dash a set distance in the 8 cardinal directions. Lets say I essentially want the player to be able to dash 5 units in any of the 8 cardinal directions, and I'd like to write a script that calculates the force required to do that, then applies that force. How would I go about setting up this math?

Note: if needed, the character's mass is 1, their drag is 0, and the gravity in the game is set to -20 in the y value.

2. ### AlTheSlacker

Joined:
Jun 12, 2017
Posts:
60
https://en.wikipedia.org/wiki/Equations_of_motion
Allows you to understand the distance (s), time (t), velocity (u and v), acceleration (a) relationship. Scroll down to the bit "Constant translational acceleration in a straight line" to avoid the rather intimidating start.

Force = mass x acceleration lets you work out the force to apply (the time will be the fixed physics time step or multiples of).

You will need to compensate for your gravity, you can use the F = ma above to work out the force due to gravity.

unityunity