# Rotate Gravity 90 degrees for one object.

How do I rotate a player character’s gravity 90 degrees on button press? An example of what I want it to do is when you press page down, the gravity of ONE object / character only rotates 90 degrees clockwise. I have tried almost every possible way to get it to work. Please help ASAP.
Below is what I currently have as a script that is attached to the character:

``````var forceToAdd : Vector3 = Vector3(5,5,0);
var obj:GameObject;
private var other:RotateObject;
var rotating : boolean = false;
var changegravityminus :boolean = false;
var changegravityplus :boolean = false;

function Start() {
other = obj.GetComponent(RotateObject);
}

function Update () {
if (other.gravity == 1){
transform.Rotate (0,0,0);
Physics.gravity = new
Vector3(0f,-9.81f,0f);
}

if (other.gravity == 2){
transform.Rotate (0,0,90);
Physics.gravity = new
Vector3(-9.81f,0f,0f);
}

if (other.gravity == 3){
transform.Rotate (0,0,90);
Physics.gravity = new
Vector3(0f,9.81f,0f);
}

if (other.gravity == 4){
transform.Rotate (0,0,90);
Physics.gravity = new
Vector3(9.81f,0f,0f);
}

if(Input.GetKeyDown (KeyCode.PageUp)&& rotating==false){
changegravityminus=false;
rotating=true;
transform.Rotate (0,0,-90);
Physics.gravity =Quaternion.Euler(0, 0, -90) * Physics.gravity;
rotating=false;
changegravityminus=true;
}

if(Input.GetKeyDown (KeyCode.PageDown)&& rotating==false) {
rotating=true;
transform.Rotate (0,0,90);
Physics.gravity =Quaternion.Euler(0, 0, 90) * Physics.gravity;
rotating=false;
}
}
``````

if(Input.GetKeyDown(“Fire1”)){
yourDifferentGravityGO.rigidbody.useGravity = false;

``````    //a flag to refer to in fixed update so you can change it's behaviour
yourDifferentGravityGO.isGravityDifferent = true;

//then apply a constant force in Fixed Update in the direction you want
}
``````