I'll try to give as much information as i can.
Only the tilemap is flipped because then you can obtain objects originally out of your range, avoid enemies (if they're in the ground), get to the room's exit (my game is based on them), etc.
(open image in new tab to see better).
I maked it using scale.y/x = -1:
extends Node2D
func _process(delta):
if Input.is_action_just_pressed("ui_accept"):
if $TileMap.scale.y == 1: #Normal state.
$TileMap.scale.y = -1 #Flipped_v state.
$Label2.set_text("Flipped_v = true")
else:
$TileMap.scale.y = 1
$Label2.set_text("Flipped_v = false")
if Input.is_action_just_pressed("ui_cancel"):
if $TileMap.scale.x == 1:
$TileMap.scale.x = -1 #Flipped_h state.
$Label.set_text("Flipped_h = true")
else:
$TileMap.scale.x = 1
$Label.set_text("Flipped_h = false")
But because my character it's not flipped along with the tilemap, it can get stuck in tiles:

So i tried this (thanks to @TwistedTwigleg):
var P_pos = $TileMap.world_to_map($Player.get_position()) #Transforms player's position in pixels to cells.
var P_stuck_in_tiles = $TileMap.get_cellv(P_pos)
if P_stuck_in_tiles != -1: #-1 = no tile.
$Player.position.y -= 80 #Pixels (My tiles are 40x20 instead of 32x32 because being the tilemap origin in the center of the screen gives me problems and i still prefer my game being 16:9(1920, 1080)).
print(b)
It works well if tilemap it's in normal state:

But in the rest of states (flipped_v, flipped_h and both_on)... either happens this:

or:

So i analized the coordinates of P_pos
if they were different to what i wanted and, yes, it was that but i decided to draw a red circle in my character's position in case that makes it more understandable:

The problem is that even if my kinematicbody2d isn't a children of tilemap, this last one still always conserves player's original position like if it was (the player's coordinates will always be (-23, 22), (-19, 10), (20, 9), etc. no matter in which state the tilemap it's):
It's like this but without the sprite and collision shape flipping along with the kinematicbody's position:
It's not my game's idea.
What i want it's this (in text):
Normal (P_pos = (-23, 22), (-19, 10), (20, 9), etc).
Flipped_h (P_pos = (22, 22), (10, 10), (9, 9), etc).
Flipped_v (P_pos = (-23, -23), (-19, -19),(20, 20), etc).
Both_on (P_pos = (22, -23), (10, -19), (9, 20), etc).
My nearest try:
extends Node2D
var F_V = false #Flipped_v
var F_H = false #Flipped_h
var B_O = 0 #Both_on
func _process(delta):
if Input.is_action_just_pressed("ui_accept"):
if F_V == false:
$TileMap.scale.y = -1
F_V = true
B_O += 1
$Label2.set_text("Flipped_v = true")
else:
$TileMap.scale.y = 1
F_V = false
B_O -= 1
$Label2.set_text("Flipped_v = false")
if Input.is_action_just_pressed("ui_cancel"):
if F_H == false:
$TileMap.scale.x = -1
F_H = true
B_O += 1
$Label.set_text("Flipped_h = true")
else:
$TileMap.scale.x = 1
F_H = false
B_O -= 1
$Label.set_text("Flipped_h = false")
var P_pos
var Difference_B_O = Vector2(-1820, 896)
var Difference_F_H = Vector2(-1820, 0)
var Difference_F_V = Vector2(0, 896)
if F_H == true:
P_pos = $TileMap.world_to_map($Player.get_position() - Difference_F_H)
if F_V == true:
P_pos = $TileMap.world_to_map($Player.get_position() - Difference_F_V)
if B_O == 2:
P_pos = $TileMap.world_to_map($Player.get_position() - Difference_B_O)
if B_O == 0:
P_pos = $TileMap.world_to_map($Player.get_position())
var P_stuck_in_tiles = $TileMap.get_cellv(P_pos)
if P_stuck_in_tiles != -1:
$Player.position.y -= 4
$Label3.set_text("Cell =" + " " + str(P_pos) + " " + str(P_stuck_in_tiles))
:)
:(
I hope this serves more.