Hi all. I read in a tutorial that in order to find the angle between two vectors you need to normalise and perform a dot product on them, then provide this dot product to the arc cosine function to get the angle. Here's my code below and I keep getting NaN errors, which seems to be because the dot product isn't unit length, although the tutorial hadn't mentioned this.

Thanks for the quick reply. I've just put in your code and it's stopped the errors, but the angle doesn't look right in the scene. This is for the enemies in the scene. They're able to fire projectiles at the player, but in order to do that the angle between the player and enemy must be determined. As it stands they just appear to be firing up from -45 to 45 degrees.

Thanks Riven, just corrected that. Now the dot product method works, but the angle's still a bit off. I've translated it from radians into degrees too and it doesn't seem to firing in the correct direction.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org