Download

[SOLVED] Limiting Missile Fire by Angles

Hello All. I’m trying to get the angle between the direction my Hover Tank is facing and where the locked target is actually at. At launch, the weapon “turret” faces the same direction as my Hover Tank So, by my thinking, I’d like the forward vector of my “turret” to define the direction my missile is facing. It will launch in that direction. I’d like to know what angle, off the nose of my turret, the locked target is at.

Here are my assumptions:
Directly to my right = 90deg
Directly to my left = 270deg (or is it -90deg?)
Directly in front of me = 0deg and
Directly behind me = 180deg (or is that -180deg?)

How do I calculate the angle so I know how many degrees to the left or right of my turret the locked target is at? I will set the missile to lose lock if the target is more than 70deg off my nose - either left or right. That’s either >70deg OR <-70deg or it is >70deg OR -290deg off my nose. I’ve been trying “Find Look at Rotation” and using a “Dot Product” node with no success so far. I just don’t understand the math in 3D space…

Currently, the missile will fire backwards if the locked target is directly behind me. This is the kind of behavior I’m trying to correct. I’d only like the missile to engage in a somewhat realistic manner since it can’t just flip around at launch, you know?

Thank you - any and all help is appreciated!