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

AI shakes and spins when colliding with other objects

This topic is 908 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
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!