this is my whole code
public class GravityControl : MonoBehaviour {
private bool isgrounded;
public GameObject Player;
public GameObject Planet;
public float gravity = 10;
public float movespeed = 5;
public float jumpheight = 30;
Vector2 PlayerPosition;
Vector2 PlanetPosition;
Vector2 direction;
public float jetthrust = 25;
bool inorbit = true;
public float rotationamount = 0.0000000001f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void FixedUpdate(){
PlanetPosition = Planet.transform.position;
PlayerPosition = Player.transform.position;
direction = PlanetPosition - PlayerPosition;
if (inorbit == true) {
rotationupdate (direction);
applygravity (direction, gravity);
}
if (Input.GetButton ("MoveLeft") && isgrounded == true) {
moveplayer (-transform.right, movespeed);
}
if (Input.GetButton ("MoveRight") && isgrounded == true) {
moveplayer (transform.right, movespeed);
}
if (Input.GetButtonDown ("Jump") && isgrounded == true) {
Player.rigidbody2D.AddForce (transform.up * jumpheight);
isgrounded = false;
}
if (Input.GetButton ("jetbootup")) {
Player.rigidbody2D.AddForce (transform.up * jetthrust);
}
if (Input.GetButton ("CWRotation") && inorbit == false) {
Player.rigidbody2D.AddTorque (-rotationamount);
}
if (Input.GetButton ("CCWRotation") && inorbit == false) {
Player.rigidbody2D.AddTorque (rotationamount);
}
}
void OnCollisionEnter2D(Collision2D other){
if (other.gameObject.tag == "planet") {
isgrounded = true;
}
}
void OnTriggerEnter2D(Collider2D other){
if (other.tag == "orbit") {
Planet = other.transform.parent.gameObject;
inorbit = true;
}
}
void OnTriggerExit2D(Collider2D other){
if (other.tag == "orbit") {
inorbit = false;
}
}
void rotationupdate(Vector2 direction){
float angle = Mathf.Atan2 (direction.y, direction.x) * Mathf.Rad2Deg;
Quaternion rotation = Quaternion.Euler (0, 0, angle + 90);
Player.transform.rotation = rotation;
}
void moveplayer(Vector2 movedirection, float movespeed){
Player.rigidbody2D.AddForce (movedirection * movespeed);
}
void applygravity(Vector2 direction, float gravity){
Player.rigidbody2D.AddForce (direction.normalized * gravity);
}
}
but the problem is with the addtorque part. When the astronaut in my game is not in the orbit of any planet in my 2d game, i want the player to be able to rotate him slowly to steer him. However, no matter how much i shrink the value of rotationamount, the astronaut spins like crazy the second i press the button.