Page 1 of 1
Making an image face a point
Posted: Fri Sep 05, 2008 9:30 pm
by SamPerson12345
I'm making a top down shooter and I wanted the player image to face the cross hair. The problem is I have no idea how to get an angle with two points. Can someone please help?
Re: Making an image face a point
Posted: Fri Sep 05, 2008 10:20 pm
by conman420
Use this math:
Code: Select all
local x2, y2 = position
local x1, y1 = position
local ang = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi
We need lua syntaxing code boxes!
Re: Making an image face a point
Posted: Fri Sep 05, 2008 10:29 pm
by SamPerson12345
Thanks for that
.