Says InputManager has no definition to OnFoot and I fallowed the tutorial exactly as it says

Assets\Script\Player\PlayerInteract.cs(36,34): error CS1061: ‘InputManager’ does not contain a definition for ‘OnFoot’ and no accessible extension method ‘OnFoot’ accepting a first argument of type ‘InputManager’ could be found (are you missing a using directive or an assembly reference?)

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

public class PlayerInteract : MonoBehaviour
{
private Camera cam;
[SerializeField]
private float distance = 3f;
[SerializeField]
private LayerMask mask;
private PlayerUI playerUI;
private InputManager inputManager;
// Start is called before the first frame update
void Start()
{
cam = GetComponent().cam;
playerUI = GetComponent();
inputManager = GetComponent();
}

// Update is called once per frame
void Update()
{
playerUI.UpdateText(string.Empty);
//create a ray at the center of the camera, shooting outwards.
Ray ray = new Ray(cam.transform.position, cam.transform.forward);
Debug.DrawRay(ray.origin, ray.direction * distance);
RaycastHit hitInfo; // variable to store our collision information.
if (Physics.Raycast(ray, out hitInfo, distance, mask))
{
if (hitInfo.collider.GetComponent() != null)
{
Interactable interactable = hitInfo.collider.GetComponent();
playerUI.UpdateText(interactable.promptMessage);
if (inputManager.OnFoot.Interacted.triggered)
{
interactable.BaseInteract();
}
}
}
}
}

Do you have the case right? Are you sure you didn’t name OnFoot “onFoot” or something else? We can’t diagnose this without seeing your InputManager code. Also, use code tags.

or its inputManager, not InputManager…

(I know ive seen this question more than once so the answer is, it is a typo)

If that was the case, we’d be getting an error saying InputManager isn’t defined, not OnFoot.

No, see the variables the CLASS is called InputManager, the variable is inputManager…

Please actually look at the code.

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

public class PlayerInteract : MonoBehaviour
{
    private Camera cam;
    [SerializeField]
    private float distance = 3f;
    [SerializeField]
    private LayerMask mask;
    private PlayerUI playerUI;
    private InputManager inputManager;
    // Start is called before the first frame update
    void Start()
    {
        cam = GetComponent<PlayerLook>().cam;
        playerUI = GetComponent<PlayerUI>();
        inputManager = GetComponent<InputManager>();
    }

    // Update is called once per frame
    void Update()
    {
        playerUI.UpdateText(string.Empty);
        //create a ray at the center of the camera, shooting outwards.
        Ray ray = new Ray(cam.transform.position, cam.transform.forward);
        Debug.DrawRay(ray.origin, ray.direction * distance);
        RaycastHit hitInfo; // variable to store our collision information.
        if (Physics.Raycast(ray, out hitInfo, distance, mask))
        {
            if (hitInfo.collider.GetComponent<Interactable>() != null)
            {
                Interactable interactable = hitInfo.collider.GetComponent<Interactable>();
                playerUI.UpdateText(interactable.promptMessage);
                if (inputManager.OnFoot.Interacted.triggered)
                {
                    interactable.BaseInteract();
                }
            }
        }
    }
}

The variable “inputManager” is of the class “InputManager.” “inputManager” is assigned via the GetComponent call in Start(). “inputManager.OnFoot” is called in Update.

The issue is that something is wrong in the InputManager class.

I did, but the fact its hard to read because people cant be bothered with code tags doesnt help… so yes, you’re right, it is a little I but in the original it looks more like a capital

It wouldn’t matter regardless because the error message still would have been different. If what you were saying was the case, the error would have been “can not convert from method group to object.”

We need to see the InputManager class since that’s where it’s supposedly missing. A link to the tutorial would help too.

Maybe this answers it Reddit - Dive into anything

Yep. It’s marked private and it’s onFoot not OnFoot. Crazy how the reddit thread is ten months old.

I have already tried the onFoot instead of OnFoot and I got an error
error CS0122: ‘InputManager.onFoot’ is inaccessible due to its protection level

did you read ALL of the linked post? about private and public?

Is it set to protected or private? Because if it is you can’t access it from outside the class. You need to set it to public for it to be accessible.

Here is the InputManager code and the tutorial I watched

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

public class InputManager : MonoBehaviour
{
private PlayerInput playerInput;
private PlayerInput.OnFootActions onFoot;

private PlayerMotor motor;
private PlayerLook look;
private PlayerInteract interact;
// Start is called before the first frame update
void Awake()
{
playerInput = new PlayerInput();
onFoot = playerInput.OnFoot;

motor = GetComponent();
look = GetComponent();

onFoot.Jump.performed += ctx => motor.Jump();
}

// Update is called once per frame
void FixedUpdate()
{
//tell the playermotortomove using the value from our movement action.
motor.ProcessMove(onFoot.Movement.ReadValue());
}
private void LateUpdate()
{
look.ProcessLook(onFoot.Look.ReadValue());
}
private void OnEnable()
{
onFoot.Enable();
}
private void OnDisable()
{
onFoot.Disable();
}
}

As we both said (and the compiler) , you cant access that its private. As the reddit thread detailed, you need to change that to public…

The first comment on the video states what’s wrong: he left out some footage showing him correcting mistakes he had made in the code. The correction in this case is like we said: change OnFoot’s permission from private to public.

9820887--1411668--upload_2024-5-7_19-31-6.png

Slight rant: I hate tutorials where the author presents the code by typing it up in the video as it enables mistakes like this. It’s not like them typing it is somehow going to make it easier to understand. Just copy and paste tested code, or show the entire class in its finished state.