0 votes

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) ).

in Engine by (122 points)

1 Answer

0 votes
Best answer

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

by (76 points)
selected by

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.