Pointing towards (facing) an actor
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.
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
Then inside the enemy constrain rotation to
vector to angle (playerx-self.x, playery-self.y)