Argument: Input Axis Horizontal is not set up.
I have followed the unity tutorial on YT (tanks). Everything works fin. Now I tryed to expand th game a little bit by using more tanks. So that you can choose which you want to drive. But now he gives me evry update the ERROR: ArgumentException: Input Axis Horizontal is not setup. To change the input settings use: Edit -> Project Settings -> Input
i know that there are some other people in this forum with the same question, but i can't find a solution for my problem.
Please help.
Sorry for my bad english...
Here is my code and apicture of the inputmanager: -GameManager -TankManager -TankMovement
private void Start()
{
selectioManager = GameObject.FindGameObjectWithTag("SelectionManager").GetComponent<SelectionManager>();
// Create the delays so they only have to be made once.
m_StartWait = new WaitForSeconds(m_StartDelay);
m_EndWait = new WaitForSeconds(m_EndDelay);
selectioManager.setTankPlayer1(0);
selectioManager.setTankPlayer2(0);
FindTanksToSpawn();
SpawnAllTanks();
SetCameraTargets();
// Once the tanks have been created and the camera is using them as targets, start the game.
StartCoroutine(GameLoop());
}
private void SpawnAllTanks()
{
m_Tanks[0].m_Instance =
Instantiate(TankPlayer1, m_Tanks[0].m_SpawnPoint.position, m_Tanks[0].m_SpawnPoint.rotation) as GameObject;
m_Tanks[0].m_PlayerNumber = 1;
m_Tanks[0].Setup();
m_Tanks[1].m_Instance =
Instantiate(TankPlayer2, m_Tanks[1].m_SpawnPoint.position, m_Tanks[1].m_SpawnPoint.rotation) as GameObject;
m_Tanks[1].m_PlayerNumber = 2;
m_Tanks[1].Setup();
}
public void FindTanksToSpawn()
{
for (int i = 0; i <= m_TankPrefab.Length; i++)
{
if (PlayerPrefs.GetInt("TankSpieler1") == i)
{
TankPlayer1 = m_TankPrefab[i];
}
}
for (int i = 0; i <= m_TankPrefab.Length; i++)
{
if (PlayerPrefs.GetInt("TankSpieler2") == i)
{
TankPlayer2 = m_TankPrefab[i];
}
}
}
public void Setup ()
{
// Get references to the components.
m_Movement = m_Instance.GetComponent<TankMovement> ();
m_Shooting = m_Instance.GetComponent<TankShooting> ();
m_CanvasGameObject = m_Instance.GetComponentInChildren<Canvas> ().gameObject;
// Set the player numbers to be consistent across the scripts.
m_Movement.m_PlayerNumber = m_PlayerNumber;
m_Shooting.m_PlayerNumber = m_PlayerNumber;
// Create a string using the correct color that says 'PLAYER 1' etc based on the tank's color and the player's number.
m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>";
// Get all of the renderers of the tank.
MeshRenderer[] renderers = m_Instance.GetComponentsInChildren<MeshRenderer> ();
// Go through all the renderers...
for (int i = 0; i < renderers.Length; i++)
{
// ... set their material color to the color specific to this tank.
renderers[i].material.color = m_PlayerColor;
}
}
private void Start ()
{
// The axes names are based on player number.
m_MovementAxisName = "Vertical" + m_PlayerNumber;
m_TurnAxisName = "Horizontal" + m_PlayerNumber;
// Store the original pitch of the audio source.
m_OriginalPitch = m_MovementAudio.pitch;
}
private void Update ()
{
// Store the value of both input axes.
m_MovementInputValue = Input.GetAxis (m_MovementAxisName);
m_TurnInputValue = Input.GetAxis (m_TurnAxisName);
EngineAudio ();
}
Answer by landon912 · Apr 05, 2016 at 12:27 PM
Without the entire script it is hard to debug.
But it looks like the tank's script is existing before you set the player number. Therefore, Start() on the tank is called with a player number that is not set up.
This is just a guess, as the entire setup is not here, and you have two Start() methods which should be resolved.
Answer by sahilsimransingh100 · Aug 12, 2020 at 03:33 AM
I suggest you only have one horizontal and vertical input either awsd or arrows remove numbers horizontal and vertical 1 and 2. well it did help me