How to find rotation angle to face actor

Hi, making a projectile with homing and I’m trying to have the projectile not home in on an actor if it is behind it. So the projectile would check with the actor and if it had to rotate 90 degrees or more in order to face it, it would decide not to home in on it. Is there a function or a formula I can use to filter this properly?

Hi!

There may be several ways to do this, but you might try this method:

  1. Get two vectors; one that faces in front of your projectile, and one that goes from your projectile to its target
  2. Get the angle between those vectors via algebra
  3. Do stuff based on the output angle

Pictures:

The function in the second image was simply made with two vector inputs, and one float output. I don’t know what conditions you want your bullet to track in, so sticking this on tick might not be the best method. Nevertheless, this code should get your logic up and running. Also, I threw this code together in the Third Person Character blueprint. You will probably want to call this from your projectile’s blueprint.

Good luck!