Dumb question, BUT how do i code an object to perform an action above player object?

B

Beersy

Guest
Im trying to have an enemy AI drop a bomb when its y is the same as the players y.
i would assume it would be in step event as:

if(y=obj_player.y)
{
action_create_object(obj_bomb,x,y)
}

but this line of code i think works if the y is literally where the players y is.
how do i code where the Y line is the same as the players Y line...i hope im asking it the right way?
 

Bingdom

Googledom
If it's a side view like Mario, you are looking at the wrong variable
Should be checking if the x-axis is the same.
 

sp202

Member
You'd need to check along the x-axis. Also, checking for the exact position above the player isn't likely to work, try a small radius within which it would detect. If you strictly want the bomb to drop when the enemy is above the player, you'd need to add a check for that too.
Code:
if abs(x-player.x)<max_dist and y<player.y
{
//drop bomb
}
 
B

Beersy

Guest
AXIS! thats exactly what i was looking for I knew there was a variable for it and i didnt know what it was but that do what i want thanks for the help!
 
Top