▲ 2 r/gamemaker
My player states won't switch
I'm trying to code an attack state, but when trying to trigger switching to the attack state, nothing happens.
//CREATE EVENT
my_spd = 2;
enum State
{
normal,
attack
}
state = State.normal;
//STEP EVENT
if keyboard_check(ord("E"))
{
switch (state)
{
case State.attack: player_attack_scr(); break;
}
}
//ATTACK SCRIPT
function player_attack_scr()
{
my_spd = 0;
if instance_place(x, y, enemy_obj) != noone
{
enemy_obj.enemy_health -= 5;
}
if ev_animation_end
{
switch (state)
{
case State.attack: break;
}
}
}
Could someone help me out?
Edit: It's been fixed. Thanks to those who helped!
u/Complex_Tour9196 — 7 days ago