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

SOLVED Help calculating the distance between the player and the enemy

Lunarium

Member
This is what i tried to do.
GML:
if (point_distance(x,y,o_clover.x,o_clover.y) < 100)

{

    sprite_index = s_boss_reach

}
Admittedly i don't know much about this topic, could be using this completely wrong. Was wondering if anyone could help.
 

FrostyCat

Redemption Seeker
See:
NEVER access a single instance by object ID if multiple instances of the object exist. This includes attempts to reference or set object.variable (which is inconsistent across exports) and using with (object) to apply actions to it (this encompasses all instances of the object instead of just the one you want). Verbally, "Dog's colour" makes sense with one dog, but not with multiple dogs.

Corollary: NEVER set or use an instance's own variables with object.variable. An instance's own variables can be referenced as-is without dot prefixes. DO NOT use self. If multiple instances of the object exists, you might end up setting the value for all instances or for some other instance (depending on the export).
 

Lunarium

Member
Thank you. There was also something wrong with the rest of the code that didn't let the script run and everything is fixed now.
 
Top