hyperreality
Member
I made an off-hand item which I'm having move based on obj.player's x and y, + or - fixed distances based on obj.player's current animation frame to account for the position of the character's hand as the sprite cycles through its animation. It works perfectly if the player is against a wall (the animation playing while the player's x,y doesn't change), but when obj.player it actually moving, the off-hand item appears behind it, only catching up once obj.player hits a collision. Similarly, the off-hand item doesn't accurately follow obj.player while jumping, and I can't figure out why that is.
Here's the off-hand item's movement code:
Thanks!
Here's the off-hand item's movement code:
Code:
var facingRight = global.facingRight;
if(facingRight = false){
switch(global.player_xFrame){
case 0:
image_angle = 135;
x = obj_player.x+6;
y= obj_player.y-24;
break;
case 2:
image_angle = 135;
x = obj_player.x+6;
y= obj_player.y-24;
break;
case 1:
image_angle = 175;
x = obj_player.x+16;
y= obj_player.y-30;
break;
case 3:
image_angle = 95;
x = obj_player.x-6;
y= obj_player.y-20;
break;
}
}
else{
switch(global.player_xFrame){
case 0:
image_angle = 225;
x = obj_player.x-6;
y= obj_player.y-24;
break;
case 2:
image_angle = 225;
x = obj_player.x-6;
y= obj_player.y-24;
break;
case 1:
image_angle = 185;
x = obj_player.x-16;
y= obj_player.y-30;
break;
case 3:
image_angle = 265;
x = obj_player.x+6;
y= obj_player.y-20;
break;
}
}