i have a tiny problem.i successfully changed the direction of gravity for the game,but am unable to change the orientation of the player based on the new direction of gravity.hope someone can help me.Here’s the script.
using UnityEngine;
using System.Collections;
public class gravity : MonoBehaviour {
// Use this for initialization
void Start () {
Physics2D.gravity=new Vector3(0,-9.81f,0) ;
}
// Update is called once per frame
void FixedUpdate () {
if (Input.GetKey ("o")) {
Physics2D.gravity=new Vector3(0,9.81f,0);
Debug.Log ("roof");
}
else if(Input.GetKey(";"))
{
Physics2D.gravity=new Vector3(9.81f,0,0);
Debug.Log ("right");
}
else if(Input.GetKey("k"))
{
Physics2D.gravity=new Vector3(-9.81f,0,0);
Debug.Log ("left");
}
else if(Input.GetKey("l"))
{
Physics2D.gravity=new Vector3(0,-9.81f,0) ;
Debug.Log ("floor");
}
}
}