Get Direction a Sprite Appears to Be Facing Relative to the Camera

39 Views Asked by At

Let's say I have a camera (player since I am making a game) at 0, 0 facing at -0.78 radians. I also have an entity or npc at -2, 2 facing at 0.78 radians. Because we are humans and we have brains, we can obviously determine that the entity appears to be facing right from the players perspective. So... how do I calculate this? I am using lua for this, but I will accept any language as an answer.

1

I've stumbled through different solutions with ChatGPT but it either misinterpreted what I asked or I couldn't make sense of it.

1

There are 1 best solutions below

1
JKAbsol On

After some thought and over simplification, I can just subtract the normalized (only positive numbers) orientations to get the difference and work from there. Angle = Player - Entity.