So I’ve made a simple move and jump code for my player, is there a way to make the player solid with no rotation? At the moment, if my player touches something, it can fall over and start rotating.
public class move : MonoBehaviour
{
public float speed = 3.0f;
private Rigidbody rb;
public float jumpspeed = 10f;
void Start()
{
rb = GetComponent<Rigidbody> ();
}
void Update ()
{
if (Input.GetKey (KeyCode.UpArrow))
{
Vector2 velocity = rb.velocity;
velocity.y = jumpspeed;
rb.velocity = velocity;
}
if (Input.GetKey (KeyCode.LeftArrow))
{
this.transform.Translate (new Vector3 (-speed * Time.deltaTime, 0, 0));
}
else if (Input.GetKey (KeyCode.RightArrow))
{
this.transform.Translate (new Vector3 (speed * Time.deltaTime, 0, 0));
}
}
}