Home > Software engineering >  ArgumentException Input Button Fire1 is not setup Unity error
ArgumentException Input Button Fire1 is not setup Unity error

Time:01-11

I am new to Unity and C# coding and I am follow a tutorial on Youtube.

This is our code so far:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
   [SerializeField] Vector2 jumpVelocity;
 
  void Update()
  {
      if(Input.GetButtonDown("Fire1")) {
       GetComponent<Rigidbody2D>().velocity = jumpVelocity;
       }
  }
}

When the tutorial instructor presses play on unity, It jumps a bit and gives him no error.

But I receive the error: ArgumentException Input Button Fire1 is not setup. To change the input setting use: Edit-> Settings -> Input

Most of the solutions say that I must capitalize Fire1 and in the code I did and I still receive the error.

Any help would be appreciated. Thanks

EDIT:

enter image description here

Here is my F1 settings

CodePudding user response:

From your post, you don't mention having followed the error's suggested resolution. That being the case, we should make sure that "Fire1" is actually defined. To do so, in the Unity Editor, select the "Edit" menu option, then select "Project Settings" (possibly just "Settings" on older Unity versions). In the popup window, look down and find "Input Manager".

Make sure that there's an entry for "Fire1" in the 'Axes' list.

It should look like this: enter image description here

You can see here all the options for what an input is. You'll also notice that in my setup, "Fire1" is the left ctrl or the left mouse button (mouse 0). You can either select an input definition that's already setup, or create "Fire1" to mimic what's in the image.

Note: as per the comments, be wary that any leading or trailing spaces aren't trimmed and can cause the issue exhibited.

  • Related