When you press certain buttons in my game, the tilemap (with enemies and objects that touch the ground but without the player) is flipped horizontally or vertically.
To make it, i did this:
if Input.is_action_just_pressed("ui_accept"): #For now "ui_accept".
if $TileMap.scale.y == 1:
$TileMap.scale.y = -1
$TileMap.scale.y = 1
if Input.is_action_just_pressed("ui_cancel"): #The same as before.
if $TileMap.scale.x == 1:
$TileMap.scale.x = -1
$TileMap.scale.x = 1
But there's a problem:
When my tilemap it's flipped horizontally, vertically or both, the coordinates of the player don't coincide with the sprite and collision shape (because is not flipped along with my tilemap) so my game detects if the player is stuck in tiles i.e in -23, 22 instead of 22, -23 like it should be.
I tried this:
var a = $TileMap.world_to_map($Player.get_position() - Vector2(-1820, 896))
var b = $TileMap.get_cellv(a)
But when i move forward, character's x position it's 21 when it should be 23 (the same vertically). Is there a way to flip the coordinates and not my character along with the tilemap?