Ambiguous call Controls.Controls()' and 'Controls.Controls()'

When I add controls = new Controls(); i get the error:
The call is ambiguous between the following methods or properties: ‘Controls.Controls()’ and ‘Controls.Controls()’
Tried copy/pasting the code from the resources:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using static Controls;

[CreateAssetMenu(fileName = "New Input Reader", menuName = "Input/Input Reader")]
public class InputReader : ScriptableObject, IPlayerActions
{
    public event Action<Vector2> MoveEvent;
    public event Action<bool> PrimaryFireEvent;
    private Controls controls;

    private void OnEnable()
    {
        if (controls == null)
        {
            controls = new Controls();
            controls.Player.SetCallbacks(this);
        }

        controls.Player.Enable();
    }

    public void OnMove(InputAction.CallbackContext context)
    {
        MoveEvent?.Invoke(context.ReadValue<Vector2>());
    }

    public void OnPrimaryFire(InputAction.CallbackContext context)
    {
        if (context.performed)
        {
            PrimaryFireEvent?.Invoke(true);
        }
        else if (context.canceled)
        {
            PrimaryFireEvent?.Invoke(false);
        }
    }
}

I think what I’d done was added a script called “Controls.cs” in the same folder, and it was getting confused between which one to use.

It could be an issue with your using statements. I see you have “using static Controls;” as well as the Unity Input System.

1 Like

Thanks, appears to be resolved by putting the correct files in the correct places :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms