detect if object is near

Any way to detect if object is near another object?

You can check the distance from one node to another, but if you want to do it often (each frame) and/or on many objects then put a collision sphere on each object and let the collision detection system do that for you.

I guess one lightweight way to do that is to compare the squared distance.

radius = 2.0
radiusSq = radius * radius
isNear = (obj.getPos() - target.getPos()).lengthSquared() <= radiusSq

Or even, if you do not want to take the Z into account:

radius = 2.0
radiusSq = radius * radius
isNear = (obj.getXy() - target.getXy()).lengthSquared() <= radiusSq