beginner problem Help Needed Error CS0103

I’m making an FPS and I’m working on a grappling hook using a youtube tutorial and I’m getting on my script the error
Assets\scripts\Grappling hook scripts\GrapplingHook.cs(28,27): error CS0103: The name ‘Fire2’ does not exist in the current context
and the warnings
Identifier uniqueness violation: ‘Name:pasted__pCylinder3, Type:Mesh’. Multiple Objects with the same name/type are generated by this Importer. There is no guarantee that subsequent imports of this asset will properly re-link to these targets.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
and
Unable to open Assets/grapplinghook.fbx: Check external application preference
here’s the code for the grappling hook

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

public class GrapplingHook : MonoBehaviour
{

    public GameObject hook;
    public GameObject hookHolder;

    public float HookTravelSpeed;
    public float PlayerTravelSpeed;

    public static bool fired;
    public static bool hooked;

    public float maxDistance;
    private float currentDistance;
    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetAxis(Fire2) && fired == false)
            fired = true;
        if (fired == true)
        {
            hook.transform.Translate(Vector3.forward * Time.deltaTime * HookTravelSpeed);
            currentDistance = Vector3.Distance(transform.position, hook.transform.position);

            if (currentDistance >= maxDistance)
                ReturnHook();

        }
       
    }
    void ReturnHook()
    {
        hook.transform.position = hookHolder.transform.position;
        fired = false;
        hooked = false;
    }
}

If “Fire2” is an axis from the InputManager, you’re probably missing some quotes:Input.GetAxis("Fire2")

I did that and that fixed one problem but now it’s showing me another it now says
Assets\scripts\Grappling hook scripts\GrapplingHook.cs(28,13): error CS0019: Operator ‘&&’ cannot be applied to operands of type ‘float’ and ‘bool’

Try this:

if (Input.GetAxis("Fire2") != 0 && fired == false)
1 Like

thanks man that fixed my issue,