• Advertisement
Sign in to follow this  

AI shakes and spins when colliding with other objects

This topic is 758 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, 

i'm having trouble with preventing my ai (zombies) from colliding with other objects (pickups, walls and obj_player)

i just started with gamemaker so i really dont know what to look for, ill post my codes below. If you need to see other codes please ask.

Thanks in advance

 

Zombie step:

 

//States
script_execute(state);
 
//Collisions
if hspeed!=0
if !place_free(x+hspeed,y)
{
    if hspeed>0 move_contact_solid(0,hspeed)
    if hspeed<0 move_contact_solid(180,-hspeed)
    hspeed=0
}
 
if vspeed!=0
if !place_free(x+hspeed,y+vspeed)
{
    if vspeed>0 move_contact_solid(270,vspeed)
    if vspeed<0 move_contact_solid(90,-vspeed)
    vspeed=0
}

 

//Move to direction
image_angle = direction - 90;
 

 

 
Script enemy follow

///scr_enemy_follow
var dis = point_distance(x,y,obj_player.x,obj_player.y);
if (!collision_line(x,y,obj_player.x,obj_player.y,obj_wall,1,1)) alerted = true;
 
if (alerted = true) && (dis <= aggroRange) && (dis > attackRange)
{
mp_potential_step(obj_player.x,obj_player.y,enemySpeed,true);
sprite_index = spr_zombie1_aggro;
image_speed = 0.16;
}
else if (alerted = true) && (dis <= attackRange)
{speed = 0;
state = scr_enemy_attack}
else
{
state = scr_enemy_static;
alerted = false
sprite_index = spr_zombie1_idle;
}
 
 

 

 

Edited by Guli1

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement