#Trajectory Prediction

1 messages · Page 1 of 1 (latest)

echo narwhal
#

So I'm currently trying to figure out how to predict the trajectory of a moving target such that even if the target is at an angle relative to the turret that's aiming at the target, the turret will still hit the target. The issue is seen illustrated on the included picture. You can see that the white lin points to the front-most capsule target as it should but the bullets (little grey pellets) are flying straight past because the capsule is at just a slight enough angle for the turrets shots to be just enough behind to not hit the target.

One could change the speed of the projectile of course which is a valid option when a player is in control but these turrets auto-target and shoot, so the prediction a human would normally do is not present. I have been thinking of an approach to try and predict the future although I'm unsure how to do it as I've not had to do it before.

#

I'm guessing I need a couple of things:

  • The speed of the target
  • The movement direction of the target
  • Perhaps the speed of the bullet?
    But how do I express that?
#

My current approach is very naive

var monsterTransform = state.EntityManager.GetComponentData<LocalTransform>(cannons[index].Target);
var cannonRotation = state.EntityManager.GetComponentData<LocalTransform>(cannons[index].TankRotationBase);

float3 lookDirection = math.normalize(monsterTransform.Position - transforms[index].Position);
#

transforms[index].Position is a turret

reef crater
#

This is not really an DOTS specific question and I think you'll find plenty of suggestions online. What I can say is it becomes harder to predict if you include air drag on the bullets. Otherwise you're in a good direction.