Announcement

Collapse
No announcement yet.

Direction to an actor, relative to players orientation

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Direction to an actor, relative to players orientation

    Hi, this may be a stupid question, but I can't figure it out by myself.
    I need to know, how I can find the direction to an actor, relatively to the players own rotation.
    In my case, I want to use this to draw the direction to objects on a compass.

    Finding the absolute direction is a piece of cake: atan2(y,x) is doing the job.
    Making it relative to the players rotation is just as easy: [direction to actor] - [rotation of player]

    But: When my players rotation switches from 180° to -180°, the relative direction switches, too. Of course, it does.
    And on my compass the objects seem to jump to a different position, which is really annoying.

    Does anyone have an idea, how to get the direction to an actor, relatively to the own orientation?
    There may be a ready-to-use-function, that I simply don't know?

    Regards
    Christian
    Last edited by chricken; 08-19-2016, 03:55 AM. Reason: Correction
Working...
X