object's distance from another

As the title implies, how would one find the distance one object is from another?

Much appreciated,
J.K. [import]uid: 66117 topic_id: 17450 reply_id: 317450[/import]

something like this will work
math.abs(obj1.x - obj1.width/2 - (obj2.x - obj2.width))
not tested and assuming you had not changed reference point of your object [import]uid: 12482 topic_id: 17450 reply_id: 66161[/import]

you can also use trigonometry to determine more accurately and even the angle to the object.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 17450 reply_id: 66437[/import]

local distance = math.sqrt( (obj1.x-obj2.x)^2 + (obj1.y-obj2.y)^2 )

distance between object’s centers [import]uid: 65903 topic_id: 17450 reply_id: 66962[/import]