My code needs the name of the axis to get (Input.GetAxis) I know horizontal and vertical for x and y but z im not sure I did try depth but that did not work.
Here is my code
using UnityEngine;
using System.Collections;
public class player : MonoBehaviour {
public float playerspeed =5.0f;
// Use this for initialization
void Start () {
//Player Spawn Point
transform.position = new Vector3 (0, 3, 0);
}
// Update is called once per frame
void Update () {
transform.Translate (Vector3.right * Input.GetAxis("Horizontal") * playerspeed * Time.deltaTime);
transform.Translate (Vector3.forward * Input.GetAxis ("Z") * playerspeed * Time.deltaTime);
}
}
1 Answer
1
You can assign, rename and configure your axes in the Input Manager (Edit->Project Settings->Input). There is no Z-axis because this would not make sense. An axis just describes how the controller input is interpreted. For the joysticks it means that X-axis is horizontal movement (stick moved left or right) and Y-axis is vertical movement (stick moved up or down) by default, however everything is adjustable in the Input Manager.
Just get your movement on the z-axis from the input of the vertical axis!
transform.Translate (Vector3.forward * Input.GetAxis ("Vertical") * playerspeed * Time.deltaTime);
But if you prefer, just go into the input manager and rename the vertical axis to āZā. 
Monogon, I know this is an old post but this worked for me. I had the same issue as ringthane. Much appreciated.
ā aperez440Worked for me too. Many thanks!
ā diliupg