I've just introduced a variable called 'being' to be use alongside 'state' (thanks lcl). Sometimes it seems to work, other times there are bugs like being stuck to the ground or jumping midair while diagonally moving.
there are two additional constants for the variable 'being', they share values with two existing constants.
- Code: Select all
#define STOP_LEFT 0
#define OFF_GROUND 0
#define STOP_RIGHT 1
#define ON_GROUND 1
#define RUN_LEFT 2
#define RUN_RIGHT 3
#define JUMP_LEFT 4
#define JUMP_RIGHT 5
#define FALL_LEFT 6
#define FALL_RIGHT 7
#define SHOOT_LEFT 8
#define SHOOT_RIGHT 9
At the end of player Collision top side of ground I set being to ON_GROUND.
- Code: Select all
switch(state)
{
case STOP_LEFT:
break;
case STOP_RIGHT:
break;
case RUN_LEFT:
break;
case RUN_RIGHT:
break;
case JUMP_LEFT:
ChangeAnimation("Event Actor", "StandRight", NO_CHANGE);
state = STOP_LEFT;
break;
case JUMP_RIGHT:
ChangeAnimation("Event Actor", "StandLeft", NO_CHANGE);
state = STOP_LEFT;
break;
case FALL_LEFT:
ChangeAnimation("Event Actor", "StandRight", NO_CHANGE);
state = STOP_LEFT;
break;
case FALL_RIGHT:
ChangeAnimation("Event Actor", "StandLeft", NO_CHANGE);
state=STOP_RIGHT;
break;
case SHOOT_LEFT:
break;
case SHOOT_RIGHT:
break;
// turning animation
}
being = ON_GROUND;
It was my hope that this condition would prevent any unintended jumping. Though when jumping diagonally you can still do a midair jump.
- Code: Select all
switch(state)
{
case STOP_LEFT:
if(being == ON_GROUND)
{
ChangeAnimation("Event Actor", "JumpRight", NO_CHANGE);
player_collider.yvelocity=-12;
state = JUMP_LEFT;
}
break;
case STOP_RIGHT:
if(being == ON_GROUND)
{
ChangeAnimation("Event Actor", "JumpLeft", NO_CHANGE);
player_collider.yvelocity=-12;
state = JUMP_RIGHT;
}
break;
case RUN_LEFT:
ChangeAnimation("Event Actor", "JumpRight", NO_CHANGE);
player_collider.yvelocity=-12;
state = JUMP_LEFT;
break;
case RUN_RIGHT:
ChangeAnimation("Event Actor", "JumpLeft", NO_CHANGE);
player_collider.yvelocity=-12;
state = JUMP_RIGHT;
break;
case FALL_LEFT:
break;
case FALL_RIGHT:
break;
case SHOOT_LEFT:
break;
case SHOOT_RIGHT:
break;
// turning animation
}
I have a collision finish event with the ground, it's very short.
- Code: Select all
being = OFF_GROUND;
And I have the .ged if anyone would like to see it.