Draw a line between two objects and get the angle

A

Andres Molina

Guest
Hi, im actually creating a 2D game when the player needs to use a sword, to simulate the attack i thought in making 2 different objects (player body, player hand) then i could draw a line from the center of the player to the center of the hand, and use that line to set the angle of the sword the player will be using. The question is, how i do that? Thanks. Im pretty new at this.
 

obscene

Member
var sword_angle=point_direction(x,y,hand.x,hand.y);

Something like that. You don't actually want to draw a line, just draw the sword at hand.x,hand.y at sword_angle.
 
A

Andres Molina

Guest
var sword_angle=point_direction(x,y,hand.x,hand.y);

Something like that. You don't actually want to draw a line, just draw the sword at hand.x,hand.y at sword_angle.
Thats exactly what i needed. Thanks a lot
 
Top