How can I make a block disappear when hit from below by a jumping player

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jackson King

I’m new to Godot and am trying to add a Super Mario like mechanic to my game.

I want my brick block to disappear when my “Player” jumps up and hits the block from below, but otherwise act with normal collision. However, I’m not sure what script to add to make the block disappear, as well as where to add it to (just the “Block” sprite, or does the script need to be added to the “Player” as well?)

Preferably, I would want this to work with blocks in a tilemap, since that would make the stage creation process much simpler then copying a block over and over again. But after a bit of research it looks like this might not be possible because tilemaps don’t see collisions as collisions with individual blocks but instead collisions with the whole tilemap. So, I’d be fine copying a block if it comes to it.

Currently my block has a CollisionShape that allows the player to not jump through it.

:bust_in_silhouette: Reply From: kidscancode

it looks like this might not be possible because tilemaps don’t see collisions as collisions with individual blocks

This is true, but there’s nothing stopping you from using the position of that collision to find which cell in the TileMap you collided with.

This is a common enough question that I have made a tutorial explaining how to do it:

TileMapCollisions

This works, but results in a couple of frames of lag. Is it possible to minimize the delay between hitting a block and the block disappearing?

Jackson King | 2019-04-08 18:21

I am not experiencing any lag, much less a couple of frames. There may be something else going on.

kidscancode | 2019-04-08 18:26