Page 1 of 1

Hand animations

Posted: Fri Dec 30, 2011 5:53 pm
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.

Re: Hand animations

Posted: Fri Dec 30, 2011 5:59 pm
[code]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[/code]

Re: Hand animations

Posted: Fri Dec 30, 2011 6:04 pm
[QUOTE=Yann] [code]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[/code][/QUOTE]

@YANN: You are really into math, arent you?

Re: Hand animations

Posted: Fri Dec 30, 2011 6:17 pm
Wow haha thanks alot Yann

Re: Hand animations

Posted: Fri Dec 30, 2011 6:20 pm
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.

Re: Hand animations

Posted: Fri Dec 30, 2011 6:23 pm
Oh ok I got around in the events haha sorry I dont recognize everything yet haha but thanks realy.

Re: Hand animations

Posted: Fri Dec 30, 2011 6:51 pm
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)Yann2011-12-30 18:52:47