How do I make motion relative to the ground the player is on

Godot 4

I want to make an fps in space and I want players to be able to walk on walls as the floor.

How do you want to transition to a new surface? If I collide with the ceiling will it automatically change orientation so I can stand on the ceiling?

Cast rays and if it collides with the floor or wall you can slowly start to spin before the collision it may just be disorienting to player either way.

Once the player is oriented to the surface you could employ a few tricks. Cast a ray from feet and if it collides apply force twords surface to keep them attached. Area3d gravity overrides that only effect the player body.