Guided Missle Lock
I'm adding guided missles to my game and would like them to lock onto a particular entity in my world. Parsing through the list of entities is not a problem. Rather, I'd like some feedback, thoughts or ideas for algorithms to acquire the lock. Thanks.[/align]
forward 180° up to a certain range?
Factoring in range to target might be a good idea. I'm not a guided munitions expert or anything, but I was under the impression that radar lock had a range beyond which is wasn't able to achieve good tone.
Yes. I was thinking of casting a ray for the view and seeing if any lockable entities were within a set range. I'm guessing that is how it is done.
Unless you're planning on having shedloads (read: 1,000+) lockable entities in you entire game world, worrying too much about this algorithm is just premature optimization. I find that's it's a lot easier to optimize when you have something that's running slow, instead of optimizing before it's going slow.
I've implemented this a couple of times before. Are you looking for help with a particular part of the algorithm, or are you not sure of the general approach to take?
I'm looking for a general approach. I'll be able to hande it from there.
Thanks.
Thanks.
As I recall, mine worked something like this:
- Subtract the position of the target from the position of the missile and normalize it.
- Take the cross product and dot product between the missile's current direction and that vector to get axis and angle.
- Clamp the angle to some arbitrary maximum (or minimum if negative) so that the missile doesn't instantly reorient directly toward the target.
- Rotate the missile along the computed axis/angle.