As far as I know, this formula does work properly. This formula only works if the surface the object is launched from and is flying over is flat.

= Speed of projectile

= Distance traveled

= Gravity down force

= Angle of the gun

That formula gives me the speed of the object as a scalar, as far as I know.

And this is what a friend had told me about how to get it as a vector

Would I be able to solve for the scalar velocity if I use the first equation as ?

If this helps, here is what he had said:

you'll need first those values for calculations

Angle on which gun is pointing at(or range you want to, but then you'll need to decice wether the gun is in low/high angle)

Speed of projectile(i don't think rockets will be easy to calculate)

and Gravity strength(default = 9.8).

for now, i'll give an example. in this case, a gun firing a bullet in a 100 m/s velocity, 30 degrees angle of launch, and a 10 m/s² gravity acceleration(making it easier for you to understand).

you'll need to determine the range on which the projectile will land on.

sin(30 degrees)*100 = 50 m/s Y velocity at launch.

cos(30 degrees)*100 = 50*(3^0.5) x velocity at launch.

next step is calculating flight time. in this case, (Y velocity / Gravity)*2(because your projectile will fall down too). with the specified conditions, this equals to a 10 second flight time.

now, multiplying the X velocity by the flight time, you get a 500(3^0.5) meter flight distance*

*=Eliminating other factors, like air friction, and making sure the ground is flat.

you'll need lots of math to do that... good luck