How to use get_floor_angle in Godot with C# / Align the player with the floor

Godot Version

Godot_v4.2.1

Question

Hello, I’m new to Godot or any scripting really and I would like to have the Player standing on the slope and aligned with the floor instead of just hovering on it. I read online that it could be possible with get_floor_angle and then changing the rotation of the player with that, but I don’t know how to use it in C#.


The player should be rotated like the red line I edited in.

I can’t really provide much more information because I really don’t know anything and I’m a complete beginner

Thank you for your answer
Do you also know how that would work with C#? I think your answer is for GDScript(?)

I’m trying to get it to work with

CharacterBody2D.GetFloorNormal();

Because I use a CharacterBody2D for the Player Character. Not sure if that’s the correct way though