Advertisement

AI shakes and spins when colliding with other objects

Started by March 26, 2016 10:42 AM
-1 comments, last by MMMMMMMN 8 years, 9 months ago

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;
}

This topic is closed to new replies.

Advertisement