Check if position is free

Hi Everyone,

I’m making a game where an object can slide up, down, left or right if the position is free on a grid (ie there isn’t another object in that space).

How do i go about testing if a position at specific point/grid has an object or not? In other game engines I would do a test at a specific X.Y is others i would do a raycast to see if there is a collision within a certain range.

Any assistance is greatly appreciated.

There’s an “If position is within an object” (or something like that) condition you can you to test is a specific X:Y position is within an object (i.e. an object it sitting at that position).

That is what i was looking for. Thanks.

Next part of this challenge then… So for testing I made it so if it detects object “Block” it deletes object “Block”. Is there a way that if it detects any object, it deletes that object?

Off the top of my head, you could create a group with all objects in it and use that. But there might be an easier way I haven’t thought of…

OOO… Didn’t see that option. But yes that did the trick!

Now I just have to figure out why the object is moving even if there is an object in the way.

Ok, i can’t figure out why this isn’t working as expected.

When I click an object i want it to test if there an object next to the one i’m clicking. What it is doing is just moving the object even if there is already an object in the way.

Can you upload your game file, or at least post a screenshot of the relevant events?

Here you go. I tried to post an image earlier but it wanted a URL.
Fritz It.rar (5.4 KB)

I think using a group here to test whether a position is free or not isn’t working as expected unfortunately…

You could check out my project (in my signature below) where I’m doing a similar thing. I’ve done it by creating a grid in a structure variable, and tracking which object type is in which grid cell (so checking for an object in an adjacent cell is as simple as checking the value of a variable).

Maybe others have a better solution for you though…?