How to make my character to always be in top of the tiles?

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

When you press certain buttons, the tilemap flips vertical or horizontally.
The problem is that the player could get stuck in the collision shape of a tile.
How i could transport my character to the top of the tiles when stuck in one?

What have you tried to solve issue already?

Reloecc | 2020-09-17 06:59

I used RayShape2d and it worked for my original question, but more important than the character being over a tile its that the player always has to be in the nearest free space, being the priorities up and down (depending on the position of the center of the collision shape, it will go to one direction or the other (if in the middle of the tile, then up) ) and left or right if there’s no space in the previous directions.

Gonz4 L | 2020-09-17 22:55

Sounds complicated… I would flip a tilemap around the player (if possible by game design)? So you’ll sure there is allways going to be a space for a player.

Reloecc | 2020-09-18 04:54

Yeah, i know. If i don’t find the way to do it relatively soon, then maybe that will be ok with an area2d? Thanks!

Gonz4 L | 2020-09-18 06:14

:bust_in_silhouette: Reply From: IvanVoirol

The easiest way would be to put your character node last in the tree, but you can also edit the Z index parameter of your character node (1 instead of 0 as default).

if op wrote “on top” he means “on the ground”, not “visible as topmost” … in fact he’s asking how to move sprite by 24 pixels… :wink:

Reloecc | 2020-09-17 13:30

Oh… then I can’t answer :confused:

IvanVoirol | 2020-09-17 16:14

Exactly Reloecc, that’s what i mean.

Gonz4 L | 2020-09-17 22:42