Check if Grid has a collision


(blameMike) #1

Hi there,

I’m working on some pathfinding stuff and I need to determine if a grid node collides with an entity, but I don’t see a good way to do that. Is there a method that just says “yes, this tile has a solid collision on it”?

Thanks in advance.


(Danny) #2

Check out the documentation

getTile(column:uint = 0, row:uint = 0):Boolean

Returns true if it’s solid, false if it’s not. Probably.

This might be something.

usePositions : Boolean
If x/y positions should be used instead of columns/rows.

(blameMike) #3

Thanks for the response. I thought that just returned true or false if there was a tile in that position.


(Ultima2876) #4

A Grid is like a tilemap except each tile is just a ‘true’ or ‘false’ value. If you set your grid up correctly that true or false value can be used to represent whether the tile is solid or not, or if you like you could set it up to represent whether a tile exists there or not. The difference only depends on how you define it when you set your tiles in your game :slight_smile:


(blameMike) #5

Thanks for the reply, Ultima. I’ll try to set it up that way.


(christopf) #6

Hi i’m in a similiar situation and this may help me. But i was wondering how you get your grid tiles recognized as solid. do you have to setTile first so it detects it when you use getTile or are all grid tiles “naturally” solid? If yes to the setTile, is there a way to easily make all tiles in the grid solid?

to now i was working with the map-entities type set to “solid” and the hitboxes created with the grid. this works on collision checking but i think not for getTile or am i wrong? (maybe its because my checking method is wrong but since i work with a keyput and trace to find out if its working i found now way around this “blind” checking)

e/ i just checked the declaration of loadFromString and found it already setTile every 1 of my XML i guess. so it probably is my checking method :confused:

e²/ i got it, was my way to check it. getTile works fine. sorry for spamming this thread ._.