Y
Yvalson
Guest
so I have enemies that move along a grid as they follow the path to the player.
I have make them change sprites if their direction changes but for some reason it always takes like 2 seconds before the sprites are the good ones
here is the code:
///movement
if( direction = 0){
sprite_index = Spr_Mognorian_Walk_Right
}
if( direction = 90){
sprite_index = Spr_Mognorian_Walk_Up
}
if( direction = 180){
sprite_index = Spr_Mognorian_Walk_Left
}
if( direction = 270){
sprite_index = Spr_Mognorian_Walk_Down
}
if(path_position = 1){
if( direction = 0){
sprite_index = Spr_Mognorian_Idle_Right
}
if( direction = 90){
sprite_index = Spr_Mognorian_Idle_Up
}
if( direction = 180){
sprite_index = Spr_Mognorian_Idle_Left
}
if( direction = 270){
sprite_index = Spr_Mognorian_Idle_Down
}
}
if(path_speed = 0){
if( direction = 0){
sprite_index = Spr_Mognorian_Idle_Right
}
if( direction = 90){
sprite_index = Spr_Mognorian_Idle_Up
}
if( direction = 180){
sprite_index = Spr_Mognorian_Idle_Left
}
if( direction = 270){
sprite_index = Spr_Mognorian_Idle_Down
}
}
///path
RepothPosx = (Obj_Repoth1.x div 20) * 20 + 10
RepothPosy = (Obj_Repoth1.y div 20) * 20 + 10
alarm[0] = 30
//follow path
if (mp_grid_path(global.grid, path, x, y, RepothPosx, RepothPosy, 0)){
path_start (path, 1, path_action_stop, false)
}
I have make them change sprites if their direction changes but for some reason it always takes like 2 seconds before the sprites are the good ones
here is the code:
///movement
if( direction = 0){
sprite_index = Spr_Mognorian_Walk_Right
}
if( direction = 90){
sprite_index = Spr_Mognorian_Walk_Up
}
if( direction = 180){
sprite_index = Spr_Mognorian_Walk_Left
}
if( direction = 270){
sprite_index = Spr_Mognorian_Walk_Down
}
if(path_position = 1){
if( direction = 0){
sprite_index = Spr_Mognorian_Idle_Right
}
if( direction = 90){
sprite_index = Spr_Mognorian_Idle_Up
}
if( direction = 180){
sprite_index = Spr_Mognorian_Idle_Left
}
if( direction = 270){
sprite_index = Spr_Mognorian_Idle_Down
}
}
if(path_speed = 0){
if( direction = 0){
sprite_index = Spr_Mognorian_Idle_Right
}
if( direction = 90){
sprite_index = Spr_Mognorian_Idle_Up
}
if( direction = 180){
sprite_index = Spr_Mognorian_Idle_Left
}
if( direction = 270){
sprite_index = Spr_Mognorian_Idle_Down
}
}
///path
RepothPosx = (Obj_Repoth1.x div 20) * 20 + 10
RepothPosy = (Obj_Repoth1.y div 20) * 20 + 10
alarm[0] = 30
//follow path
if (mp_grid_path(global.grid, path, x, y, RepothPosx, RepothPosy, 0)){
path_start (path, 1, path_action_stop, false)
}