Adopting gravity

I’m having a problem with my game where the player falls backwards when it tries to go up a ramp.

Background info: The player has 4 spherical colliders under each corner of its model in order for it to hover above ground at a set distance, this works and is good apart from when I try to go up a ramp and the front 2 colliders hit the ramp and bounce up causing the player object to fall onto its back.

What I'd like to do is have a area aligned on the ramp so that when the player enters the area it inherits a gravity that is angled such that the ramp is the new horizon and when it exits it inherits a standard gravity that (the gravity it started with). So far this is the code I tried, however it never appeared to work.
    public class Gravity : MonoBehaviour {
    	public float gravity = 9.5f;
    	public Rigidbody player = null;
    	public GameObject ORBIT = null;
    	bool AG = true;
    	
    	void OnCollisionEnter(Collision col){
    		if(col.gameObject.CompareTag ("Angle Box")){
    			AG = false;
    			player.AddRelativeForce(col.transform.forward * gravity);
    		}
    	}
    	void OnCollisionExit(Collision col){
    		if(col.gameObject.CompareTag ("Angle Box")){
    			AG = true;
    		}
    	}
    	void update(){
    		if (AG == true){
    			player.AddForce (transform.forward * gravity);
    		}
    	}
    }

[My code is messy, I’m only 17 and I’m self-taught]

I hope I’m understanding what you are asking…

You want when the player enters this (“Ramp”) to inherit gravity to (“slide”) him down?

if so you can do something like.

(CODE IS UNTESTED) you might have to make it do this.gameObject.Physics, etc. (IDK THOUGH)

 void OnCollisionStay(Collision col){
if(col.gameObject.CompareTag ("Angle Box")){
AG = false;
Physics.gravity = new Vector3(0,-10,-10); 
}
}

Looks like a job for custom “gravity” rather than Unity’s built-in one. Basically, you can raycast downwards relative to the player and then get the normal of the surface under him.

Once you get the normal (ie the direction), apply gravity using the normal as the direction. Or something like that.

See this thread for some example code.

Character align to surface normal ???