0 Favourites

# Hand animations

• 7 posts
• Ok so I was wondering how I would make the hands of my character follow my mouse position a a certain radius of my character. What I mean is, I have my character and my hands in seperate sprites, the hands follow my mouse a bit like a cursor but it can only go a certain distance from my character.

• ``````Global Variable HandDistance = 40 // Distance between body and hand in pixel
System: Every tick
-> Hand: set X to cos(angle(Player.X,Player.Y,Mouse.X,Mouse.Y))*HandDistance
-> Hand: set Y to sin(angle(Player.X,Player.Y,Mouse.X,Mouse.Y))*HandDistance``````
• ``````Global Variable HandDistance = 40 // Distance between body and hand in pixel
System: Every tick
-> Hand: set X to cos(angle(Player.X,Player.Y,Mouse.X,Mouse.Y))*HandDistance
-> Hand: set Y to sin(angle(Player.X,Player.Y,Mouse.X,Mouse.Y))*HandDistance``````

@YANN: You are really into math, arent you? <img src="smileys/smiley2.gif" border="0" align="middle" />

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Wow haha thanks alot Yann <img src="smileys/smiley16.gif" border="0" align="middle" />

• Eh I guess this is in real programming or its in the events ? sorry haha I'm not use to the program yet and is there a window to see code ? cuz I know a bit of javascript from using Unity engine, I didnt look at what language C2 can use yet.

• Oh ok I got around in the events haha sorry I dont recognize everything yet haha but thanks realy.

• When you get the hang of vector math it's always the same thing

cos(a) gives you an X projection of the unit vector at angle a

sin(a) gives you an Y projection ot the unit vector at angle a

Just have to scale a unit vector by the magnitude (distance) you want it to be and you're done.

(vector and position are almost the same thing... they share common notation)

• 7 posts