- #1
SoBinary
- 1
- 0
I have a character who needs to jump to a certain height, I want to calculate his initial vertical velocity so that he can achieve that height. Distances and speeds are in logical pixels per second.
The character's position is stored in a 2D vector \begin{pmatrix} x \\ y\end{pmatrix}, and movement is enacted by adding a velocity vector \begin{pmatrix} vx \\ vy\end{pmatrix} to the position vector at every frame. Gravity, with value \begin{pmatrix} 0 \\ -9.8\end{pmatrix} is added to the velocity vector if the character is not in the air.
At frame n, the vy_n can be expressed as vy_n = vy_(n-1) + Gravity, which gives position at frame n y_n = y_{(n-1)} + (vy_n * Δ) where Δ is delta time (the seconds in between two frames, say 1/60)
So, in order to get the character to height h, what should the initial vy be?
The character's position is stored in a 2D vector \begin{pmatrix} x \\ y\end{pmatrix}, and movement is enacted by adding a velocity vector \begin{pmatrix} vx \\ vy\end{pmatrix} to the position vector at every frame. Gravity, with value \begin{pmatrix} 0 \\ -9.8\end{pmatrix} is added to the velocity vector if the character is not in the air.
At frame n, the vy_n can be expressed as vy_n = vy_(n-1) + Gravity, which gives position at frame n y_n = y_{(n-1)} + (vy_n * Δ) where Δ is delta time (the seconds in between two frames, say 1/60)
So, in order to get the character to height h, what should the initial vy be?
Last edited: