Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- the way i do it is
- hands are part of an array
- how you handle this array is up to you, really, but mine's defined like so
- for(var i = 0; i <= 1; i++)
- {
- handx[i] = 0
- handy[i] = 0
- handspd[i] = 0
- handgoalx[i] = 0
- handgoaly[i] = 0
- handrot[i] = 0
- handgoalrot[i] = 0
- }
- handx and handy are the position of a hand relative to the player's x and y position, rather than their position in the world
- handspd pertains to how fast a hand can move in a given animation, used in a lerp function
- handgoalx and handgoaly are the position the hands want to move to
- handrot is the hand's rotation
- handgoalrot is the rotation the hand wants to achieve
- setting a hand's position is handled with a script
- mine is ///hand_pos_set(hand_index,x,y,speed,rot)
- hand_index refers to which hand you're setting a position for, x and y set the goal x and y, speed sets handspd, rot sets handgoalrot
- if you really wanted you could add a handrotspd variable but i didn't find it necessary for my purposes here
- this entire code block handles hands
- //"hand"le hands hahaha
- for(var i = 0; i <= 1; i++)
- {
- if round(handx[i]) != handgoalx[i]
- {
- handx[i] = lerp(handx[i],handgoalx[i],handspd[i])
- handy[i] = lerp(handy[i],handgoaly[i],handspd[i])
- //handrot[i] = point_direction(handx[i],handy[i],handgoalx[i],handgoaly[i])
- }
- if round(handx[i] = handgoalx[i])
- handspd[i] = 0
- var _diff = angle_difference(handrot[i],handgoalrot[i])
- handrot[i] -= 0.25 * _diff
- }
- there might be better ways of handling this
- but this is how i do it
- from here, drawing hands is simple
- i layer hand 0 behind the player, and hand 1 in front of the player
- //draw back hand and player
- draw_sprite_ext(_handindex,1,x+handx[0],y+handy[0],right,1,handrot[0],c_white,1)
- draw_sprite_ext(sprite_index,image_index,x,y,right*hsquash,vsquash,rot,c_white,1)
- //draw front hand and weapon
- draw_sprite_ext(wep_sprt[wep],0,x+handx[1],y+handy[1],right,1,handrot[1],c_white,1)
- draw_sprite_ext(sprHand,0,x+handx[1],y+handy[1],right,1,handrot[1],c_white,1)
- i should note that _handindex is something that pertains to a hand's sprite index. there's only one case where a hand's sprite index changes for me so far, but it's probably smart to build a system around that too
- was that good enough of an explanation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement