Unity 3D – Get Axis – rigidbody.velocity
1. Create a Plane (Ground) with:
– Mesh Collider
2. Create over the plane a Sphere with:
– Mesh Collider
– Rigid Body
– PlayerController.JS:
#pragma strict function Start () { } // Theese variables are public to make the code easy-reusable // You can setup theese variables from Inspector var speed : float; function FixedUpdate () { // Get User Input START var moveHorizontal : float= Input.GetAxis ("Horizontal"); var moveVertical : float= Input.GetAxis ("Vertical"); // Get User Input END var movement : Vector3= new Vector3 (moveHorizontal, 0.0f, moveVertical); rigidbody.velocity = movement * speed; }