0 votes

Hello i have a gridmap with tiles in different sizes. The user can set cells in this gridmap, but I need to check if the space is occupied before (a tile can reach over to other tiles).

I tried to use an area, but areas can't detect the collision of staticbodys from a meshlib.

Is there any easy solution or do I need to use raycasts?

in Engine by (37 points)

Have you tried looking into simple collision detection? For example, I've toyed with axis-aligned bounding boxes (AABB). If you can, get an AABB for the potential spot in theGridMap and check it against what the user wants to place there.

any other links? i dont understand your idea :)

You wrote that the collisions of Areas can't detect the StaticBodys of the GridMap cells. Why not have an AABB (the 3D equivalent of the Rect2) which takes the place of any currently-occupied spaces? When a user tries to place a cell in some location, first check the AABB of the potential cell against what may be currently occupying that location.

Did you find a solution for it ?

1 Answer

+1 vote

Why not just maintain a simple 2D array that represents the "occupied" state of your map? So, each time a User attempts to drop a tile, you just check the same position in the 2D array to see if it's empty or not. If it is, allow the tile to be dropped and update the cell in the array to indicate that tile is occupied...

by (16,852 points)

then i would need to calculate the occupied space by an object first, because an object can be bigger than one tile and the tile can also be rotatet.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.