How to make my character move up until it's out of any tile?

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

When you press certain buttons in my game, the tilemap is flipped horizontally or vertically (however the player and maybe enemies and objects remain the same).
I tried this:

#Area2D belongs to the player.
func _on_Area2D_body_entered(body):
  if body == $TileMap:
    $Player.position.y -= 12 #Starting at that number the character moves.

But it only works to get out of one tile when what i want is to do it until the player it’s out of any tile (and also make it replace the default system that sends you to the right or left (unless there’s no space up and down) ).

:bust_in_silhouette: Reply From: Brightlight studios

Well you see the function only calls once, you can call it more than once in the process function by

func escape():
  var bodies = $Area2D.get_overlapping_bodies()
   for body in bodies:
      if body is TileMap:
        $Player.position.y -= 12

Then call this function in the process function or anywhere you want to hope it helps

Thanks! I just have two more questions related to this one.

Gonz4 L | 2020-09-25 18:57