• Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!

Windows [SOLVED] make enemy go towards me only at certain distance?

working on this same game found a enemy code a while back and used it and it works fine! not complex at all the enemy comes at me nothing else to it, but I want the enemy to only chase the player only after it gets so close (~10 blocks away)

i typed this in:
if(point_distance(obj_player.x, obj_player.y, x, y) <= 10)
{
move_towards_point(obj_player.x, obj_player.y, 2);
}

...but for some reason it does not work i think its something to do with the <= but ive tried doing > and take out the = but for some reason it doesn't work and I can't seem to wrap my noob head around it! help!
 
point_distance() returns the distance in pixels. So you are checking for a distance of 10 pixels.

What's your block width in pixels? If it's 32 pixels wide, then if you want to check for a distance of 10 blocks, change the value of 10 to 320 (10 x 32).
 
point_distance() returns the distance in pixels. So you are checking for a distance of 10 pixels.

What's your block width in pixels? If it's 32 pixels wide, then if you want to check for a distance of 10 blocks, change the value of 10 to 320 (10 x 32).
wow of course its something so simple but i don't think i'd ever find that out on my own, thankyou brother!
 
Top