Hi,
as the topic says, I'm trying to implement artillery in my rts project.
I know the position of the enemy at the moment of the shot, but I can't figure out how to create a fake arch that the projectile is following until it hits.
my code until now looks like this, which kind of works, but the arch is too long so it completely misses the target
# move the projectile towards the enemy (projectile is already in line with the target upon instancing)
set_translation(get_translation()-get_transform().basis.z * muzzle_velocity * delta)
# calculate the distance (target_vec = transform of target during shot)
var current_dist = self.global_transform.origin.distance_to(target_vec)
# try to use a function to displace the y value of the projectile to have an arch like flight path
var flight_vec = ((-(current_dist*current_dist)+enemy_distance*current_dist))/(enemy_distance)
# apply y change (start_pos = muzzle height of the firing unit)
transform.origin.y = flight_vec + start_pos
Or maybe someone has a better idea on how to implement the artillery projectile?
Thanks for reading