playMaker

Author Topic: Leading a Target with Smooth Look At  (Read 2219 times)

jayhfd

  • Junior Playmaker
  • **
  • Posts: 71
Leading a Target with Smooth Look At
« on: May 06, 2013, 03:05:19 AM »
Hi,
I'm having some issues developing spaceship shooting AI that can accurately fire and lead its target.

Currently I'm aiming using Look At, and I'm looking at the target's position + velocity. I've also adjusted for the bullet speed and my distance from the target, and I believe I also need to somehow account for the frame rate(?). I have implemented this, but its still not perfect. There's probably some other things I need to account for as well.

I have two issues to resolve:

1. I'm using Look At to ensure I'm aiming exactly where I want. This mostly works, however I'd like to use Smooth Look At to give the space ship a more realistic turning speed. How would I adjust for this? At the moment, using it just gives me a lagged effect where I'll constantly shoot behind my target. Alternatively, would Vector3 Rotate Towards (somehow) work better? I'm kind of unsure how that's used.

2. DeltaTime. I've read that for leading targets, you need to account for the movement into the next frame by using some sort of framerate time/FPS numbers, however when I use DeltaTime, I'm returning 0. I'm using a turn based system and pausing/unpausing, and figure this is the problem somehow?

Thanks for any help!
Regards,
Jay

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Leading a Target with Smooth Look At
« Reply #1 on: May 09, 2013, 02:54:32 AM »
Hi,

 smooth look at is the way to go I guess.

 now, for delta tie, don't rely on what Unity shows you on it's interface, delta time is a very very small float, and therefore it's rounded to 0 when showed to you... that's stupid, but that's the way it works.

bye,

 Jean