How to change player gravity in a 3d space?

Hi I wanted to make a proof of concept 3d platformer demo where the player (just a single player, not the environment) could change their orientation in the scene for a short period of time, allowing them to walk on surfaces other than the floor. I have attached a rigid body to my player controller to allow for the physics to happen. I also wanted this to be able to happen only when a player touches the surface and not in the middle of touching one.

Is it possible for this to be done in Unity? I’ve tried to search other places for answers but I could not find one.

you can set the gravity for every rigidbody by typing Physics.gravity = new Vector(0, -1, 0);

and for changing it you on touch can look up the OnTriggerEnter Function