How do I use a tile sprite with a custom hitbox?

I’m working on a classic platformer and wanted to make the regular tiled sprite platform have a little bit of depth to it. I’d like the characters to not sit on the very top of the tile sprite, but rather a few pixels drown from the top to appear as if walking on the platform not on the top of the graphic. I know I can make a regular sprite object and use a custom hitbox, but I like the ease of building levels with the tile sprite and I assume there are some good performance reasons to use a tile sprite for platforms that will be used so much.

Basically trying to make the version of this screen shot on the left work for the game.

Hi, if you check Silver-Streak’s Not-a-vania example GDevelop 5 you can see that he used different background images which have no hitboxes and built the platforms (which represent the hitboxes) with sprite-objects that are hidden at the beginning of the scene.

I may be wrong but performance is probably not an issue, even with a lot of sprite-objects.

Thanks I haven’t seen that before. I did think about using two sprites, one the actual platform, the second showing the depth without a hitbox. I was hoping for a simple solution, some way of doing an offset on the actual tile sprite to make board design easier than managing multiple sprites.

1 Like

Thinking through the two sprite option, one tile sprite with the standard hitbox, one without a platform behavior to sit on top and add the depth, could this be accomplished more automatically by creating the “top” sprite and linking it to each instance of the tile platform at run time? Are their other good methods of auto generating sprites and attaching them to the “parent/bottom” sprite? This way I could build levels with just the “bottom” tile sprite and during run time the depth adding “top” sprite would be created for each?

I’d suggest creating an external event script that goes through all your tiled sprites in the scene and creates a hidden platform object for each tiled sprite, with a width of the tiled sprite and positioned a few pixels below the tiled sprite origin.

By using an external script you can call or link it from any scene, and if you make changes, it’ll be in just the one script.

If the tiled sprite moves, then use the sticker extension to attach the platform object to the tiles one.


Thanks @MrMen I’ll try the external event script and explore the sticker extension.