• 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!

script animation problem(unsolved)

F

fxokz

Guest
In my script my goal is to make it so that after the player has finished his melee animation it goes back to his normal state. The problem is after the first frame of the attack animation it goes back to his normal state.

scr_player_melee
Code:
hsp = 0;
vsp = 0;
sprite_index = spr_player_melee;
image_speed = 0.2;
if (image_index >=1) && (image_index <=3)
{
    with (instance_create(x, y, obj_hitbox))
    {
        image_xscale = other.image_xscale
        with  (instance_place(x, y, par_enemy))
        {
            if (hit == false)
            {
                hit = true;
                // insert whatever
            }
        }
    }
}
state = playerState.normal;
collision_check();
im not sure on how to solve this. the tutorial i watched didnt use scripts (shaunjs tutorial)
 
Remove the second to last line
Code:
state = playerState.normal;
Make sure your scr_player_melee is a state, so that it is repeatedly being called.

In your player object, create an animation end event, and you can add something along the lines of this:
-Assuming the player state is stored in a variable named state
Code:
  if(state == scr_player_melee){ //or whatever your melee state is titled
    state = playerState.normal;
  }
 
F

fxokz

Guest
Remove the second to last line
Code:
state = playerState.normal;
Make sure your scr_player_melee is a state, so that it is repeatedly being called.

In your player object, create an animation end event, and you can add something along the lines of this:
-Assuming the player state is stored in a variable named state
Code:
  if(state == scr_player_melee){ //or whatever your melee state is titled
    state = playerState.normal;
  }
yes the melee script only executes when the playerState is melee. Im still not 100% sure about this solution. I hope it doesnt cause problems later down the track. thanks for your help

edit: i would much rather want it so that i can change the state back to normal within the melee script to keep things neat but oh well.
 
yes the melee script only executes when the playerState is melee. Im still not 100% sure about this solution. I hope it doesnt cause problems later down the track. thanks for your help

edit: i would much rather want it so that i can change the state back to normal within the melee script to keep things neat but oh well.
I actually think using an else statement might solve your problem.
Try:
Code:
hsp = 0;
vsp = 0;
sprite_index = spr_player_melee;
image_speed = 0.2;
if (image_index >=1) && (image_index <=3)
{
   with (instance_create(x, y, obj_hitbox))
    {
        image_xscale = other.image_xscale
        with  (instance_place(x, y, par_enemy))
        {
            if (hit == false)
            {
                hit = true;
                // insert whatever
            }
        }
    }
}
else{
  state = playerState.normal;
}
collision_check();
I guess I read through your post too quickly and missed that. But, I think this should just be the solution.
 
F

fxokz

Guest
I actually think using an else statement might solve your problem.
Try:
Code:
hsp = 0;
vsp = 0;
sprite_index = spr_player_melee;
image_speed = 0.2;
if (image_index >=1) && (image_index <=3)
{
   with (instance_create(x, y, obj_hitbox))
    {
        image_xscale = other.image_xscale
        with  (instance_place(x, y, par_enemy))
        {
            if (hit == false)
            {
                hit = true;
                // insert whatever
            }
        }
    }
}
else{
  state = playerState.normal;
}
collision_check();
I guess I read through your post too quickly and missed that. But, I think this should just be the solution.
I tried it and the same problem still persists. Is there any other check i can do in order to run this line after the animation completes?
Code:
[CODE]state = playerState.normal;
ughh im confusing myself trying to figure out why it wont work
 
Top