Godot Version
4.6 stable
Question
Heya, i'm trying to make a Mario sort of game on my journey of learning Godot. I've implemented the camera, coins, movement and item blocks and it works pretty well, however i wanted to do the mushroom as well. The issue regarding the mushroom is that i'm trying to make it change movement direction everytime it hits a wall, just like in the original Super Mario Bros. However, this isn't working, as i'm using a TileMapLayer, and the mushroom will change direction upon contact with the TileMapLayer even if it's not touching the wall, but instead the floor. How would I make it detect the wall only? Thanks for any help!

Code:
extends RigidBody2D
@onready var Direction := 75
func _physics_process(delta: float) β void:
linear_velocity = Vector2(Direction, linear_velocity.y)
func _hit(body: Node2D) β void:
if body is CharacterBody2D:
queue_free()
elif body is TileMapLayer:
print(βyesβ)
Direction = -Direction