Jump to content
  • Advertisement
Sign in to follow this  
Julian Buursink

AI shakes and spins when colliding with other objects

This topic is 989 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


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:


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)
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)


//Move to direction
image_angle = direction - 90;


Script 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)
sprite_index = spr_zombie1_aggro;
image_speed = 0.16;
else if (alerted = true) && (dis <= attackRange)
{speed = 0;
state = scr_enemy_attack}
state = scr_enemy_static;
alerted = false
sprite_index = spr_zombie1_idle;



Edited by Guli1

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!