R
RoyalApocalyptic
Guest
SOLVED!
The solution, for anyone else having this issue was to run the arms "follow" code in the End Step event rather than the step event.
In my game, the player's head and arms are separate from the body and point to the mouse and follow the player.
The head in this case works 100% fine, snapping to the player perfectly and not falling behind.
But the arms trail behind a bit, not going the same speed as the character's torso.
It is a very minor trail and looks fine while running, but if the character picks up speed or falls at all, the arms start to trail behind significantly and looks horrible.
Here is an example.
Left is what happens when the character is at a high speed.
Right is what it is SUPPOSED to be.
Code:
Head code:
if obj_player.sprite_index = spr_player_right
|| obj_player.sprite_index = spr_player_jump_right
|| obj_player.sprite_index = spr_player_fall_right
{
x = obj_player.x;
y = obj_player.y-4;
}
if obj_player.sprite_index = spr_player_left
|| obj_player.sprite_index = spr_player_jump_left
|| obj_player.sprite_index = spr_player_fall_left
{
x = obj_player.x;
y = obj_player.y-4;
}
Arms code(Yes I know it can be condensed a bit but I am very early in dev of this game at the moment.) :
if obj_player.sprite_index = spr_player_right && mouse_x > x
|| obj_player.sprite_index = spr_player_right_walk && mouse_x > x
|| obj_player.sprite_index = spr_player_fall_right && mouse_x > x
|| obj_player.sprite_index = spr_player_jump_right && mouse_x > x
{
obj_arms.x = obj_player.x-4;
obj_arms.y = obj_player.y+4;
}
if obj_player.sprite_index = spr_player_left && mouse_x < x
|| obj_player.sprite_index = spr_player_left_walk && mouse_x < x
|| obj_player.sprite_index = spr_player_fall_left && mouse_x < x
|| obj_player.sprite_index = spr_player_jump_left && mouse_x < x
{
obj_arms.x = obj_player.x+4;
obj_arms.y = obj_player.y+4;
}
if obj_player.sprite_index = spr_player_right && mouse_x < x
|| obj_player.sprite_index = spr_player_right_walk && mouse_x < x
|| obj_player.sprite_index = spr_player_fall_right && mouse_x < x
|| obj_player.sprite_index = spr_player_jump_right && mouse_x < x
{
obj_arms.x = obj_player.x+4;
obj_arms.y = obj_player.y+4;
}
if obj_player.sprite_index = spr_player_left && mouse_x > x
|| obj_player.sprite_index = spr_player_left_walk && mouse_x > x
|| obj_player.sprite_index = spr_player_fall_left && mouse_x > x
|| obj_player.sprite_index = spr_player_jump_left && mouse_x > x
{
obj_arms.x = obj_player.x-4;
obj_arms.y = obj_player.y+4;
}
The solution, for anyone else having this issue was to run the arms "follow" code in the End Step event rather than the step event.
In my game, the player's head and arms are separate from the body and point to the mouse and follow the player.
The head in this case works 100% fine, snapping to the player perfectly and not falling behind.
But the arms trail behind a bit, not going the same speed as the character's torso.
It is a very minor trail and looks fine while running, but if the character picks up speed or falls at all, the arms start to trail behind significantly and looks horrible.
Here is an example.
Left is what happens when the character is at a high speed.
Right is what it is SUPPOSED to be.
Code:
Head code:
if obj_player.sprite_index = spr_player_right
|| obj_player.sprite_index = spr_player_jump_right
|| obj_player.sprite_index = spr_player_fall_right
{
x = obj_player.x;
y = obj_player.y-4;
}
if obj_player.sprite_index = spr_player_left
|| obj_player.sprite_index = spr_player_jump_left
|| obj_player.sprite_index = spr_player_fall_left
{
x = obj_player.x;
y = obj_player.y-4;
}
Arms code(Yes I know it can be condensed a bit but I am very early in dev of this game at the moment.) :
if obj_player.sprite_index = spr_player_right && mouse_x > x
|| obj_player.sprite_index = spr_player_right_walk && mouse_x > x
|| obj_player.sprite_index = spr_player_fall_right && mouse_x > x
|| obj_player.sprite_index = spr_player_jump_right && mouse_x > x
{
obj_arms.x = obj_player.x-4;
obj_arms.y = obj_player.y+4;
}
if obj_player.sprite_index = spr_player_left && mouse_x < x
|| obj_player.sprite_index = spr_player_left_walk && mouse_x < x
|| obj_player.sprite_index = spr_player_fall_left && mouse_x < x
|| obj_player.sprite_index = spr_player_jump_left && mouse_x < x
{
obj_arms.x = obj_player.x+4;
obj_arms.y = obj_player.y+4;
}
if obj_player.sprite_index = spr_player_right && mouse_x < x
|| obj_player.sprite_index = spr_player_right_walk && mouse_x < x
|| obj_player.sprite_index = spr_player_fall_right && mouse_x < x
|| obj_player.sprite_index = spr_player_jump_right && mouse_x < x
{
obj_arms.x = obj_player.x+4;
obj_arms.y = obj_player.y+4;
}
if obj_player.sprite_index = spr_player_left && mouse_x > x
|| obj_player.sprite_index = spr_player_left_walk && mouse_x > x
|| obj_player.sprite_index = spr_player_fall_left && mouse_x > x
|| obj_player.sprite_index = spr_player_jump_left && mouse_x > x
{
obj_arms.x = obj_player.x-4;
obj_arms.y = obj_player.y+4;
}
Last edited by a moderator: