Hello I have a problem of making sure the monster is facing the correct direction towards the player locations. The (x,y) coordinates for every object start is in the top left? Right now the code is as simple as:
if player.x \<= game.sMob\_1.x and player.y \>= game.sMob\_1.y then game.sMob\_1.rotation = 90 -- left elseif player.x \>= game.sMob\_1.x and player.y \>= game.sMob\_1.y then game.sMob\_1.rotation = 270 -- right elseif player.x \<= game.sMob\_1.x and player.y \<= game.sMob\_1.y then game.sMob\_1.rotation = 0 -- down elseif player.x \>= game.sMob\_1.x and player.y \<= game.sMob\_1.y then game.sMob\_1.rotation = 180 -- up end
Obviously there are some logical problems for certain angles, could someone direct me to a theory post on this topic, I understand its 100% a math problem and I need to designate specific spots for the up, down, left, right and take into account both the physics bodies on their locations which is needing their center mass.
Thank you for your time.