• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

help with colision code?

kureoni

Member
thats the basic movement code for the obj_enemies


GML:
 if(instance_exists(obj_player)){
mp_potential_step(obj_player.x, obj_player.y, spd, obj_colision)

image_angle = point_direction(x, y, obj_player.x, obj_player.y);
what i want to do is:
when the obj_enemies touch a obj_colision (that includes other enemies, walls etc)
the obj will be repelled a few pixels to the oposite side it is looking at

i did that with the player movement script to prevent that:
GML:
if (move_right && !place_meeting(x+spd,y, obj_colision)){

    x+=spd;

}

if (move_down && !place_meeting(x, y+spd, obj_colision)){

    y+=spd;

}

if (move_up && !place_meeting(x, y-spd, obj_colision)){

    y-=spd;

}











if (move_left && place_meeting(x-spd,y, obj_colision)){

    x+=spd;

}

if (move_right && place_meeting(x+spd,y, obj_colision)){

    x-=spd;

}

if (move_down && place_meeting(x, y+spd, obj_colision)){

    y-=spd;

}

if (move_up && place_meeting(x, y-spd, obj_colision)){

    y+=spd;

}
and it works perfectly, i just dont know how to do that on the mobs
help??

(the enemies image_angle follows the player position, so right now when the enemies turn around they are going inside walls and getting stuck etc)
 
Top