• 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!

mp potential step

K

kmce

Guest
I have this code

Code:
///Move towards John

if distance_to_object(obj_john_torso_walking) < 100
    {
    mp_potential_step (obj_john_torso_walking.x+5,obj_john_torso_walking.y,1,false);

    }

This is in the enemy object and makes the enemy move towards the player. But I want him to basically be able to go to obj_john_torso_walking.x+5 or obj_john_torso_walking.x-5, is there anyway I could do this.

Ive tried

Code:
///Move towards John

if distance_to_object(obj_john_torso_walking) < 100
    {
    mp_potential_step (obj_john_torso_walking.x+5 ||obj_john_torso_walking.x-5 ,obj_john_torso_walking.y,1,false);

    }
aswell as

Code:
///Move towards John

if distance_to_object(obj_john_torso_walking) < 100
    {
    mp_potential_step (obj_john_torso_walking.x+5,obj_john_torso_walking.y,1,false) || mp_potential_step (obj_john_torso_walking.x-5,obj_john_torso_walking.y,1,false);

    }
But these dont seem to work. Is there actually a way to do it
 
L

Linkruler

Guest
Have you tried using the place_meeting command?

if place_meeting (x+5,y,obj_john_torso) || place_meeting (x-5,y,obj_john_torso)
{
//code
}
 
K

kmce

Guest
Have you tried using the place_meeting command?

if place_meeting (x+5,y,obj_john_torso) || place_meeting (x-5,y,obj_john_torso)
{
//code
}
and not use the
if distance_to_object(obj_john_torso_walking) < 100 part. I really need that part cause tells the enemies when to move?
 
L

Linkruler

Guest
Hmm, I haven't had any experience with the distance_to_object command yet, so it's hard for me to say unless you tried testing them alongside each other
 
Top