This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

So I'm making a platformer game that uses tiles from a tilemap, and I was wanting to add a function where if one of my character's feet is standing on the edge of the platform, but the other is hanging off and not touching anything, my player would change into a different sprite. (Kind of like from Spelunky, where you stand on an edge and lose your balance.) So it seemed to me like a pretty simple task to overcome, but after testing around with raycasts, area2ds, and more, it simply just won't detect the ledge. Either I'm not using these tools properly, or there's a different way. Any help is appreciated.

in Engine by (14 points)

You need to include more detail, as you're probably just missing a setting or something.

The way I'd go about it is simple, just have two raycasts, one for each side of the player hitbox's bottom. If they're both intersecting an object then the player is on solid ground, if only one of them is then the player is not.

Check the collision layers and collision masks to make sure they're set up correctly. There's not much people can do to help you without any info, i.e. your code.

I finally figured it out after a day's, work. I put two area2ds on either bottom side of the player that are halfway in the ground, then did a similar thing like @denxi with the raycasts, but, instead with the area2ds. But instead of doing it on the tilemap, I worked the code on a staticbody2d block with the same sprite as the tilemap's, and it seemed to affect the whole tilemap even though the code was solely on the block's script, I'm not completely sure why, but it's a blessing to not have to replace the tilemap with tons of separate blocks.

Please log in or register to answer this question.

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.