• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

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