Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Roll A BAll

Discussion in 'Scripting' started by Jumping Mammoth, May 19, 2014.

  1. Jumping Mammoth

    Jumping Mammoth

    Joined:
    May 19, 2014
    Posts:
    4
    Hey guys,

    I am following the tutorial about roll a ball. To move I got this code:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour
    5. {
    6.     void FixedUpdate ()
    7.     {
    8.         float MoveHorizontal = Input.GetAxis("Horizontal");
    9.         float MoveVertical = Input.GetAxis("Vertical");
    10.  
    11.         Vector3 movement = new Vector3 (MoveHorizontal, 0.0f, MoveVertical);
    12.  
    13.         rigidbody.AddForce (movement);
    14.     }
    15. }
    But what does "Horizontal" and "Vertical" means? And how does the game know that that means the arrow keys?

    Thanks in advance!
     
  2. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
  3. Jumping Mammoth

    Jumping Mammoth

    Joined:
    May 19, 2014
    Posts:
    4
    That was what I was looking for! very much thanks! :)