N
Natonius
Guest
Hello there,
i'm new in the coding world and hope to find help here. My problem is the following: Every time an enemy does the attack-animation, the player looks at the enemy for a second. It doesn't matter if he hits the Player or not. To illustrate it, the enemy is standing (on the x-axis) to the right of the player and executes the attack-animation. The player runs towards the enemy and past him. Enemy executes the attack animation and hits nothing. Shortly after the attack animation is finished, the player switches to the left idle position (yes, i have a right and left positions for the whole moveset. image_xscale is out of question for me). This applies to both sides, in this case the player is facing to the right.
I don't want the player to stop animations (Run, role, even idle) for one frame whenever o_knight is executing the attack state. How can i handle this?
Sorry for my bad english. I hope i was able to descripe the problem. If not, let me know.
i'm new in the coding world and hope to find help here. My problem is the following: Every time an enemy does the attack-animation, the player looks at the enemy for a second. It doesn't matter if he hits the Player or not. To illustrate it, the enemy is standing (on the x-axis) to the right of the player and executes the attack-animation. The player runs towards the enemy and past him. Enemy executes the attack animation and hits nothing. Shortly after the attack animation is finished, the player switches to the left idle position (yes, i have a right and left positions for the whole moveset. image_xscale is out of question for me). This applies to both sides, in this case the player is facing to the right.
GML:
//o_knight is the enemy, o_hero the player
//o_knight's Attack-State
case "attack":
#region Attack State
set_state_sprite(s_knight_attack, 0.6, 0);
if animation_hit_frame(4)
{
audio_play_sound(a_swipe, 3, false)
if o_hero.invisible == 0 and o_hero.hp > 0
{
if o_knight.x < o_hero.x
{
create_hitbox(x, y, self, s_knight_attack_damage, 4, 4, 5, image_xscale);
o_hero.state = "knockback left";
}
if o_knight.x > o_hero.x
{
create_hitbox(x, y, self, s_knight_attack_damage, -4, 4, 5, image_xscale);
o_hero.state = "knockback right";
}
}
}
if animation_end()
{
state = "chase";
}
#endregion
break;
GML:
// create_hitbox script (thx to HeartBeast)
///@arg x
///@arg y
///@arg creator
///@arg sprite
///@arg knockback
///@arg lifespan
///@arg damage
///@arg xscale
var x_position = argument0;
var y_position = argument1;
var creator = argument2;
var sprite = argument3;
var knockback = argument4;
var lifespan = argument5;
var damage = argument6;
var xscale = argument7;
var hitbox = instance_create_layer(x_position, y_position, "instances", o_hitbox);
hitbox.sprite_index = sprite;
hitbox.creator = creator;
hitbox.knockback = knockback;
hitbox.alarm[0] = lifespan;
hitbox.damage = damage;
hitbox.image_xscale = xscale;
GML:
// Players Knockback State
case "knockback right":
#region Knockback Right State
facing = 1;
invisible = 1;
knockback_state(s_hero_hitstun_weight_right, "idle right");
#endregion
break;
case "knockback left":
#region Knockback Left State
invisible = 1;
facing = 0;
knockback_state(s_hero_hitstun_weight_left, "idle left");
#endregion
break;
GML:
// knockback_state script
///@arg knockback_sprite
///@arg next_state
var knockback_sprite = argument0;
var next_state = argument1;
set_state_sprite(knockback_sprite, 0, 0);
move_and_collide(knockback_speed, 0);
var knockback_friction = 0.3;
knockback_speed = approach(knockback_speed, 0, knockback_friction);
if knockback_speed == 0
{
state = next_state;
}
Sorry for my bad english. I hope i was able to descripe the problem. If not, let me know.
Last edited by a moderator: