position within a radius

I would love some help figuring out how to determine whether the x,y position of one object is within 10, say, or 50 or 300 pixels in any direction of x,y of a second object (second object has been dragged and released to a position).
Thanks in advance.

Kevin [import]uid: 96383 topic_id: 16467 reply_id: 316467[/import]

This is the code that I’m using in my app…

[lua]local xdist=object1.x-object2.x
local ydist=object1.y-object2.y
local radius= xx --Replaced xx with the target distance.
if ((xdist*xdist)+(ydist*ydist)) <= radius then
–do your stuff here
end[/lua]

Hope it helps :slight_smile: [import]uid: 7841 topic_id: 16467 reply_id: 61432[/import]

Super helpful, thanks so much!

Kevin [import]uid: 96383 topic_id: 16467 reply_id: 61436[/import]

No problems at all. It’s nice to be able to help someone when I always seem to be asking for help myself :slight_smile: [import]uid: 7841 topic_id: 16467 reply_id: 61438[/import]