Need help making parabolic trajectory

Godot Version

4.6.3

Question

I’m making a basketball game similar to 2k, and I want it so where if you time it right, the ball with go through the hoop perfectly via parabolic trajectory. However, i have no clue how to make something like this. any help is greatly appreciated!

I used this to figure it out: https://www.youtube.com/watch?v=4SHqHFWYg-s&t=99s

Simple physics models a parabola

Distance:

s = s_0 + v_0×t + 0.5×a×t^2

use a = -9.81 m/s^2

velocity:

v = ds/dt = v_0 + a t

these can be vector equations, so you measure distance, then height. The Tangent to the parabola should be heading almost downwards, say at angle of 60 degrees to the horizontal. (There is no arc length reparameterization of the parabola, so tangents arent so great here).

So to cut a long story short, you need a vector with the xz as cos(60) = 0.5 and the y as sin(60)=0.866

I.e. v = Vector3(0.5, 0.866, 0.0)

to get an arbitrary vector to the basket in into this simply get

var v_planar = (basket_pos -player_pos)

v_planar.y =0.0

v_planar =v_planar.normalized()*0.5

v_planar.y = 0.866

then scale by the required height, i.e. 3m higher than the players final throwing hand position

so from v= v_0+ at , v .y=0 = v_0.y -9.81*t, at max height, so

v_0.y=9.81*t

v_0.x = (0.5 /0.866)× v_0.y

So go at 60 degrees, the players arm extended might be only 1m lower than the hoop, and if the players are 7+ft tall then they can almost dunk.

Look up the old 2D game “2 tanks on a hill”.

The v_0.y initial y velocity sets the height, and time of flight, because only the y axis has acceleration.

Theres a solution here … i think ‘tg’ is ‘tan’ short for tangent …

tan a = sin a /cos a

https://physicstasks.eu/926/basketball-player