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

Legacy GM [SOLVED] Createing a radius around an object

B

Barack Pálinka

Guest
Hey guys!I'd like to create a radius around an objects so when an another object is in the radius it would do something.

In this case: i want to create a radius around a castle so when the enemies are inside the circle it would start shooting the castle.

Thanks in advance.
 
Code:
if (distance_to_object(object_name) < radius) {
    //whatever code you want when they are within the radius
}
Alternatively
Code:
if (distance_to_point(x_point,y_point) < radius) {
    //whatever code you want when they are within the radius
}
 

Simon Gust

Member
Code:
if (distance_to_object(object_name) < radius) {
    //whatever code you want when they are within the radius
}
Alternatively
Code:
if (distance_to_point(x_point,y_point) < radius) {
    //whatever code you want when they are within the radius
}
Sure that works but it's not precise and it's slower than the precise method.
You should be using point_distance(x, y, x_point, y_point).
 
Top