Angle between two points
Hey Guys,
I'm new to GameSalad so don't slam me too badly
I'm trying to find the angle between two points and from what I've been reading vectorToAngle does just that.
"Usage: vectorToAngle(x,y)
Find the angle relative to the origin, (0,0), given an X and Y coordinate. You can include an offset,(x',y'), to find an angle relative to the offset.
e.g. vectorToAngle(x-x',y-y')"
So I did this to find the angel between the player and the mouse as shown below.
vectorToAngle(( game.Mouse.Position.X - self.Position.X ),( game.Mouse.Position.Y - self.Position.Y ))
However, I was expecting a value returned in degrees but instead I am getting negative values. What am I doing wrong? :S
I'm new to GameSalad so don't slam me too badly
I'm trying to find the angle between two points and from what I've been reading vectorToAngle does just that.
"Usage: vectorToAngle(x,y)
Find the angle relative to the origin, (0,0), given an X and Y coordinate. You can include an offset,(x',y'), to find an angle relative to the offset.
e.g. vectorToAngle(x-x',y-y')"
So I did this to find the angel between the player and the mouse as shown below.
vectorToAngle(( game.Mouse.Position.X - self.Position.X ),( game.Mouse.Position.Y - self.Position.Y ))
However, I was expecting a value returned in degrees but instead I am getting negative values. What am I doing wrong? :S
Comments
vectorToAngle(self.position.x-mouse.position.x,self.position.y-mouse.position.y)
vectorToAngle( self.Position.X - game.Mouse.Position.X , self.Position.Y - game.Mouse.Position.Y )
However, I am still getting results between -180 to 180. How do I get results between 0 to 360?
abs(vectorToAngle( self.Position.X - game.Mouse.Position.X , self.Position.Y - game.Mouse.Position.Y )-180)
Now it all works
Thanks guys!