public float speed = 10; Rigidbody rb; void Start () { rb = GetComponent<Rigidbody>(); } // Update is called once per frame void Update () { float x = Input.GetAxisRaw("Horizontal"); float y = Input.GetAxisRaw("Vertical"); Vector2 direction = new Vector2(x, y).normalized; rb.velocity = direction * speed; }