• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Code Not Functioning as Intended

I have this problem with my code. I have my boss character to chase my player before attacking, but when it put the state = boss5_giant.chase in the function itself, the boss isn't following the player. It works as intended when I take out that code. I wonder what the issue might be.


GML:
function scr_boss5giant_idle(){
 
    hsp = 0
    timer += 1
    if timer >= timer_max
    {
    timer = 0
    state = choose(boss5_giant.chase_enter)
     
    }

}

GML:
function scr_boss5giant_chase_enter(){
 
 
if distance_to_object(obj_flare) > 5
{
    dir = sign(obj_flare.x - x);
    hsp = dir * walkspd;
    vsp = vsp + grv;
    state = boss5_giant.chase
}



}

GML:
function scr_boss5giant_chase(){
 
    slam_timer += 1
    if slam_timer >= slam_timer_max
    {
    timer = 0
    hsp = 0
    state = boss5_giant.slam_anticipation
    }

}
 

Nidoking

Member
By following the player, do you mean setting hsp and vsp according to where obj_flare is? Because you're not doing that in the chase function. You're only doing that in the chase_enter function.
 
By following the player, do you mean setting hsp and vsp according to where obj_flare is? Because you're not doing that in the chase function. You're only doing that in the chase_enter function.
Yes, the boss only moves in the horizontal direction when following obj_flare. I was wondering how would I fixed this issue.
 
Top