How to check if object is hitting TileMap

Goodday!

I’m trying to check if one of my actors is overlapping/hitting the walls of my tilemap but I can’t seem to figure out how to check it.

Does anybody have any idea’s?

Thanks!

Hey @Doeglas!

Can you be a little more specific? A Tilemap tends to just be arranged pieces of art with no inherent collision, so no overlap would ever be called. If you go into more detail we may be able to figure out something for you, and soon! :slight_smile:

I’m trying to make a system where a player can walk against a actor to push it forward. Im doing that by checking for a collision hit event and then moving it 0.1 from its original position. Only problem is that the item can get pushed through the walls of my tilemap and I dont really know how to fix it

Do you mean it goes behind the tilemap? Or that it goes behind the “walls” on the tilemap if pushed against it?

I hope this clears up what is happening.

For some reason it does generate a hit event whenever I hit the walls of my map and prints the tilemap name but that doesn’t work for my actor?

So I sorta found a fix. I noticed that I could check if the actor was overlapping with the tilemap. Based of that I made a system where it resets back to the last position before it overlaps which works fine.

The only thing is that it’s quit alot of nodes for something that I think could be done easier.
But my solution works fine right now so I don’t think there’s any need to change it.

1 Like

Did you gave your tiles in your tileset some collision shapes, so that the tilemap can generate some proper collision boxes/shapes for your actors to collide with? Because @Mind-Brain is right, that a normal tilemap created from a normal tileset usually comes with no collisions, because you first have to tell the tileset, which tiles shall have a collision → which will block yours and any actors way.

@Suthriel This is actually a really good infographic, can I steal this? :stuck_out_tongue:

Yes, I did add collision to the wall blocks.

Sure, go ahead and share it with the world :slight_smile:

Then i think, there might be something wrong with the collision setup of your box. As in, that it may not react to your tilemap collision. Because usually, once you have given your tiles some collision shapes, they block just like any other obstacle.

Just to confirm, can your character also walk into those walls, or does he get blocked?

Could also be the way you move the block, that this somehow overrides the collision, and it gets pushed in the walls despite a valid block happening (but it doesn´t really look that way).

One of the easier ways to test, if all collisions work properly, and everything gets blocked, is to activate gravity, and see, what lands on the tilemap or its walls, and what falls through everything ^.^

Ok, out of curiosity, i tested it myself, and it should work without any problems and any hassle. And in my case, it worked right out of the box with regular meshes.