Quick Programming Tip: Rotate Actor to Face and the Perp Dot Product

Quick Programming Tip: Rotate Actor to Face and the Perp Dot Product

Here’s a new occasional series: Quick Programming Tips! These we’ll usually be a question for a small problem, and the solution with explanation for it.

The Question:

Here’s the first one! How do I rotate progressively a entity to face another entity? For example, you have two entities Red and Blue. You want Blue to attack Red, but Blue is not facing Red, but the opposite side.

Blue is facing the opposite side.

Blue is facing the opposite side.

Obviously, if Blue attack Red without facing him, it will not look good at all. So he has to look in the direction of Red to properly attack him.

Continue reading →

Share this: