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

Input Axis Throttle is not setup Error when run game

Discussion in 'Getting Started' started by hmahdavi921, Feb 19, 2016.

  1. hmahdavi921

    hmahdavi921

    Joined:
    Dec 28, 2014
    Posts:
    6
    I use unity car pro 2.1 in my game. When run game get me this error.
    ArgumentException: Input Axis Throttle is not setup.
    To change the input settings use: Edit -> Project Settings -> Input
    AxisCarController.GetInput (System.Single& throttleInput, System.Single& brakeInput, System.Single& steerInput, System.Single& handbrakeInput, System.Single& clutchInput, System.Boolean& startEngineInput, System.Int32& targetGear) (at Assets/script/UnityCarScripts/AxisCarController.cs:32)
    CarController.Update () (at Assets/script/UnityCarScripts/CarController.cs:141)

    How to fix this?


    using UnityEngine;

    public class AxisCarController : CarController {

    public string throttleAxis="Throttle";
    public string brakeAxis="Brake";
    public string steerAxis="Horizontal";
    public string handbrakeAxis="Handbrake";
    public string clutchAxis="Clutch";
    public string shiftUpButton="ShiftUp";
    public string shiftDownButton="ShiftDown";
    public string startEngineButton="StartEngine";


    protected override void GetInput(out float throttleInput,
    out float brakeInput,
    out float steerInput,
    out float handbrakeInput,
    out float clutchInput,
    out bool startEngineInput,
    out int targetGear){


    throttleInput= Input.GetAxisRaw (throttleAxis);
    brakeInput = Input.GetAxisRaw (brakeAxis);
    steerInput = Input.GetAxisRaw (steerAxis);
    handbrakeInput=Input.GetAxisRaw (handbrakeAxis);
    clutchInput =Input.GetAxisRaw (clutchAxis);
    startEngineInput=Input.GetButton (startEngineButton);


    // Gear shift
    targetGear = drivetrain.gear;
    if(Input.GetButtonDown(shiftUpButton)){
    ++targetGear;
    }
    if(Input.GetButtonDown(shiftDownButton)){
    --targetGear;
    }

    if (drivetrain.shifter==true){
    if(Input.GetButton("reverse")){
    targetGear=0;
    }

    else if(Input.GetButton("neutral")){
    targetGear=1;
    }

    else if(Input.GetButton("first")){
    targetGear=2;
    }

    else if(Input.GetButton("second")){
    targetGear=3;
    }

    else if(Input.GetButton("third")){
    targetGear=4;
    }

    else if(Input.GetButton("fourth")){
    targetGear=5;
    }

    else if(Input.GetButton("fifth")){
    targetGear=6;
    }

    else if(Input.GetButton("sixth")){
    targetGear=7;
    }

    else {
    targetGear=1;
    }
    }
    }
    }
     
    Last edited: Feb 19, 2016
  2. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    First, use CODE tags, please...
    It writes what you need to do to fix it, where's problem? Something like "Throttle" or "Clutch" or whatever else you use is not in there.
     
    hmahdavi921 likes this.
  3. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    406
    Odd question but...

    1) Have you actually got a "Throttle" input set up in the inspector? "Edit->Project Settings->Input"

    2) And is it actually set to a proper axis or button? You not only need a "Throttle" entry, but also a valid button, I believe.

    3) Does the game still work despite the error? Are you able to test for the throttle?
     
  4. hmahdavi921

    hmahdavi921

    Joined:
    Dec 28, 2014
    Posts:
    6

    I add this inputs such as this image but don't solved.
     
  5. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    throttle and Throttle are different actually. Watch big/small letters.
     
    Tset_Tsyung and hmahdavi921 like this.
  6. hmahdavi921

    hmahdavi921

    Joined:
    Dec 28, 2014
    Posts:
    6
    Thanks a lot .It solved.
     
  7. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    406
    What Teravisor said!
     
  8. lukeluzardo

    lukeluzardo

    Joined:
    Dec 9, 2017
    Posts:
    22
    good work