Make projectile "follow" raycasting

I’m making a shooting range game with an aiming system similar to the Arma games, where the projectile is shot at the position of the mouse in the screeen.

I’m using raycasting just to visualise the position but I want to try to shoot a projectile (at the moment it’s the FP template ball) in that position, is there a way to do that and in a way that allows me to implement a “camera pan” function in the future?


Spawn (or grab from object-pool) a spline, and make the projectile march itself down the length of the spline.

Congrats! You just made a TOW-Missle!

Or since you have the hit-location at the end of the cast, and the source location of the ray (start/end) you can interp the projectile-location along that vector (minus the spline).

1 Like

Normalize(Target location - Muzzle Location) = Aim Vector
Aim Vector * muzzle velocity [float] = Projectile Aim Velocity

Pass the Projectile Aim velocity to the Projectile class (expose on spawn). In construction use the value to Set the PMC → Velocity

Let’r Rip

2 Likes

PMC will shoot toward the “Target Location”. Whether or not it makes it is up to the muzzle velocity. Too fast it’ll hit just above. Too slow it’ll fall short.

Muzzle velocity (float) is cm/s. Just take your base m/s, say 790 and add two zeros… 79000

1 Like