Hello! I am currently working on an enemies attack state however; whenever the enemy attacks it remains at the last frame of the animation. I was wondering how I could check for a collision with an object when the enemy attacks and then reset the enemy(s) state to something else? And, just in case, I did post this in the GM Help tab but I wanted to get as my heads on this as possible.
Enemy attack code beneath
function SLOTHATTACKM(){
EnCombotimer = 60;
if EnCombotimer > 0 {
EnCombotimer -= 1;
}
//How fast to move
var _spd = EnemySpeed;
//Dont move while still getting ready to jumo
if (image_index < 2) _spd = 0;
//Freeze animation while in mid-air and also after landing finishes
if (floor(image_index) == 3) || (floor(image_index) == 5) image_speed = 0;
//How far we have to jump
var _distanceToGo = point_distance(x,y,xTo,yTo);
//begin landing end of the animation once we're nearly done
if (_distanceToGo < 160) && (image_index < 5) image_speed = 1.0;
//Move
if (_distanceToGo > _spd) {
dir = point_direction(x,y,xTo,yTo);
hSpeed = lengthdir_x(_spd,dir);
vSpeed = lengthdir_y(_spd,dir);
if (hSpeed != 0) image_xscale = sign(hSpeed)
//Commit to move and stop moving if we hit a wall
if (EnemyTileCollision() == true) && (place_meeting(x, y, obj_Player)) {
xTo = x;
yTo = y;
stateTarget = ENEMYSTATE.CHASE;
stateWaitDuration = 10;
state = ENEMYSTATE.WAIT;
}
}else {
if(floor(image_index) == 5) {
x = xTo;
y = yTo;
stateTarget = ENEMYSTATE.CHASE;
stateWaitDuration = 15;
state = ENEMYSTATE.WAIT;
}
}
}