W
WimpyLlama
Guest
I am trying to make a Tower Defence game without using paths because I want the map to be randomly generated. I have not started work on the random generation yet, but I am trying to get enemy's to walk across the map. In order to do this, I created 4 path objects, each one made to move the enemy object in different directions. The problem is that it is set up so that if the enemy touches the path it moves in the corresponding direction, but when it goes from up to right or down to left, vice versa, the enemy travels on the edge. I know why this is happening, I just don't know how to fix it. Please help. Here is my code.
Code:
Step event for enemy.
//Set Movement
x = x + hsp;
y = y + vsp;
//Move On Path
if (place_meeting(x,y,obj_path_right)) {
hsp = walksp;
vsp = 0;
} else if (place_meeting(x,y,obj_path_left)) {
hsp = -walksp;
vsp = 0;
} else if (place_meeting(x,y,obj_path_up)) {
vsp = -walksp;
hsp = 0;
} else if (place_meeting(x,y,obj_path_down)) {
vsp = walksp;
hsp = 0;
}