Struggling with Tilemap collision

Godot Version

4.12

Question

I got the walls sorted, but I’m struggling to get a gravity affect on my floor tiles. I’m making a top-down JRPG style using a script for movement using move_and_slide().

If I add a collision box in the editor, and set the players mask to interact with it, this causes the player to get stuck between the walls and floors. (or sporadically bounce around sometimes, bugs are fun)
I feel like there’s something tickling my brain that I’m missing about collision layers and masks, but my experiments thus far have lead nowhere, so I am asking the community for help.

I’m only a month or two into coding, I’m passingly familiar with c++ and recently started learning gdscript alongside it.

Any help would be greatly appreciated. Or a reference to anything other than the goddotdocs regarding collision and masking would be perfect.

Are you doing 2d or 3d?

1 Like

2D, is my problem as simple as changing that?

Well in 2D there is no third axis. The player cannot go into the z dimension to not overlap with the floor. So it’s just going to get stuck somewhere.

1 Like

Ah okay, thank you, now i can at least start in the right dimension, I’m still wrapping my head around what each node is entirely capable of.

Just wanted to reply to this with: I found a solution in 2D. I’m going for like, an old school dragon quest aesthetic so I didn’t want to give up. Turns out, it was an issue with gravity. Characters and other entities in a top-down 2D game will bounce off walls and not work as intended if they are coded with gravity. Removing it entirely however solves the issue. The solution was right there in the 2D tutorial, I just needed to go back to basics.

Just in case anyone else is struggling with the same hiccup.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.