using System.Collections; using System.Collections.Generic; using UnityEngine; public class ball : MonoBehaviour { float movementSpeed=5.0f; // Start is called before the first frame update private Rigidbody rb; void Start() { rb = GetComponent (); } // Update is called once per frame void Update() { float x1 = Input.GetAxis("Horizontal"); float z1 = Input.GetAxis("Vertical"); //rb.AddForce (x1,0f,z1,ForceMode.Force); //rb.AddForce (x1,0f,z1,ForceMode.Acceleration); //rb.AddForce (x1,0f,z1,ForceMode.Impulse); //rb.AddForce (x1,0f,z1,ForceMode.VelocityChange); Vector3 direction = new Vector3(x1,0f,z1); rb.velocity = direction * movementSpeed; } }