Is there a simple way to just detect if a player or any character2D is on top of a platform?
I’m trying an if body entered: player is in area. And if player is in area and player is on floor: player is on the platform.
It’s kind of driving me insane how out of the way I have to go to just do that for each specific platform and even then there’s a lot of unwanted interactions, like if the platform is close to the ground so it ends up being activated if I’m close.
I though of making it check if the player is above it’s position when it enters but then I’d have 3 variables just for it to see if it’s on it properly, is there a simple way to just detect if anything is on top of it? Not just in the area. Like is_on_floor() but specifically only for each platform?
I think the best way would be to use a tilemaplayer node.
Go to the tileset-tab.
Look at the left hand box, into where you would usually drag the tileset, press the “+”-symbol below it and select “scenes collection”.
Now a new scenes collection, that will work a bit like a tileset will have been added. Just drag the scenes you want to use into the right hand empty box that has appeared, and now, when you place a scene from there, any attached scripts, area2d-nodes and such things will be placed alongside the rest of the tile.
Any attached scripts, area2d-nodes and such things will be included. You can even drag scenes with hundreds of nodes into scene collections, to use as tiles.
You could also just drag them in from the file registry. Main thing is to save your platforms as scenes. Then you can reuse them freely
You should use an AnimateableBody2D as a platform. That’s what it’s meant for. If you only want them to move when someone is standing on them, just make your Area2D 1 pixel high. When they enter, it moves, when they exit, it stops moving.