What a run-on sentence , I'm quite bad for using them myself but you remind me a rather hyperactive friend with how your topic reads.
There a numerous ways to get the Zombie to move towards the player, all rely on knowing the position of the player. We can get variables from an object using the syntax object.variable , therefore we can get the (x,y) coordinates by using obj_player.x and obj_player.y. Now I'm just going to do precisely what you ask for and not anything more advanced like pathfinding.
//We are close to the player so chase them
if (distance_to_object(obj_player) < 128)
{
//But not close enough to attack
if (distance_to_object(obj_player) >16)
{
//Discover there direction we need to go in
if (obj_player.x > x)
{
Dir = 1 ;
x += 2 ;
}
else
{
Dir = -1;
x -= 2 ;
}
}
else
{
//Stop and Attack in Here, by virtue of skipping the nested if statement you and moving via iterating the x variable we don't need to do anything to stop only to attack
}
}
else
{
if !place_meeting(x+2*Dir,y,obj_wall)
{
x += 2*Dir ;
}
else
{
Dir *= -1 ;
}
}
Now this will move toward the players x value while you are within a range , You should probably do a place_meeting check before moving in the first two moving parts.
Edit : I see in the time I wrote this up you bumped your topic blatantly ignoring the rules. You may only bump, that is to post immediately after one of your posts, every 48 hours. Please respect the rules.
Edited by @Alex@, 07 August 2012 - 09:12 PM.