Check an object is at specific Coordination

I’m kinda new to Defold but I was wondering if there would be an option to check if there is an object at specific coordinates.

my problem was the following I wanted to check if I would move an object into another object without moving it and then correcting like you normally would.

I used to work with Gamemaker studio 2 there exists a syntax
“instance_place(x, y, obj);” which checks if a specific object exists at the coordinates x,y. so it would be nice if there is a similar one if not other ideas would also be nice

thx

How does instance_place(x, y, obj) function actually work? In Defold every object has a position in 3D space and objects can be placed on fractional positions. What would happen if an object is positioned on x: 200.5 y: 200 z: 0 and I would call instance_place(200, 200, obj) for another object? Would the 0.5 pixel difference in horizontal position make a difference?

In your case I would probably keep track of the active objects in the game world and use a function to check if a position is occupied or not. You could use a collision system to detect this quite easily. One extension that would probably help you:

1 Like

Hi! Welcome to defold. Just a quick question: are you using the collisions system? It may be more useful in this situation. Even on my grid-based game, I check collisions using the collision polygons.

2 Likes