Null-Z
Member
so, I've got a state machine for this shadow biter here but as you can see, it seems to be skipping or going through states too quickly.
GML:
switch (state)
{
case Shadow_state.Search: {scr_ShadowSearch();}; break;
case Shadow_state.SeekLeft: {scr_ShadowSeekLeft();}; break;
case Shadow_state.SeekRight: {scr_ShadowSeekRight();}; break;
case Shadow_state.Prepare: {scr_ShadowPrepare();}; break;
case Shadow_state.Attack: {scr_ShadowAttack();}; break;
case Shadow_state.Recoil: {scr_ShadowRecoil();}; break;
}
Code:
sprite_index = spr_ShadowSearch;
image_speed = 0.1;
if instance_exists(obj_Player)
{
if point_distance(x, y, obj_Player.x, obj_Player.y) < 200
{
if x >= obj_Player.x
{
state = Shadow_state.SeekLeft;
}
else
{
state = Shadow_state.SeekRight;
}
}
}
Code:
if !place_meeting(x,y,BCH_G)
{
hspeed = 0;
state = Shadow_state.Recoil;
}
//speed control
if hspeed <= -3
{
hspeed = -3
}
//Player check
if instance_exists(obj_Player)
{
if x > obj_Player.x
{
sprite_index = spr_shadowSeekL
hspeed -= 0.1
}
}
if instance_exists(obj_Player)
{
if x <= obj_Player.x
{
hspeed = 0;
state = Shadow_state.Prepare;
}
}
Code:
if !place_meeting(x,y,BCH_G)
{
hspeed = 0;
state = Shadow_state.Recoil;
}
//speed control
if hspeed >= 3
{
hspeed = 3;
}
//Player check
if instance_exists(obj_Player)
{
if x < obj_Player.x
{
sprite_index = spr_ShadowSeekR
hspeed += 0.1
}
}
if instance_exists(obj_Player)
{
if x >= obj_Player.x
{
hspeed = 0;
state = Shadow_state.Prepare;
}
}
Code:
sprite_index = spr_ShadowBiterAtk;
image_speed = 0.1
if (image_index+image_speed >= image_number)
{
state = Shadow_state.Attack;
}
Code:
sprite_index = spr_ShadowBiteDown
image_speed = 0.1;
if place_meeting(x,y,obj_Player)
{
instance_create(obj_Player.x,obj_Player.y,OBJ_PlayerDeath);
instance_destroy(obj_Player);
}
if (image_index+image_speed >= image_number)
{
state = Shadow_state.Recoil;
}
Code:
sprite_index = spr_ShadowBiterIDl
image_speed = 0.1
if (image_index+image_speed >= image_number)
{
state = Shadow_state.Search;
}