Pointing towards (facing) an actor

dimokdimok Member Posts: 16
edited November -1 in Working with GS (Mac)
Hi!
I am making a game with the spectator (player) is looking from the top of the scene. The scene reminds of a gladiator arena. So there is the player and enemies that attack him (move towards his coordinates and decrease his health amount when collide). The dilemma is in the fact that the enemies have a front side and when they move towards the player, at some points it looks like they are walking sideways and even backwards to the player which looks awkward. Especially this issue comes up when you want to make an archer or a shooter that would stop atma certain distance from the player and shoot at him... It is impossible to arange because the shooter will be shooting somewhere else.
I was wondering if there is a way to calculate and apply the angle of rotation for the enemy so that he "faces" the player, using what the GS gives us? I was thinking that a solution to my issue might lie within one of the mathematical functions called "vectorToAngle"... What does it do?
Thanks in advance!
-Dmitry.

Comments

  • hotMagichotMagic Member, PRO Posts: 266
    yeah constrain a game variable playerx to the location of player x (within the player) so you always have his location available.

    Then inside the enemy constrain rotation to
    vector to angle (playerx-self.x, playery-self.y)
Sign In or Register to comment.