So I’m using a tutorial to make an interact script, but I just keep getting these errors. Can I get some help?
Here is the Error
Player Interact.cs(40,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 missng…)
Here are the 2 scripts within question
This is the problem script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
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);
Ray ray = new Ray(cam.transform.position, cam.transform.forward);
Debug.DrawRay(ray.origin,ray.direction * distance);
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo,distance,mask))
{
if(hitInfo.collider.GetComponent<Interactable>() != null)
{
Interactable interactable = hitInfo.collider.GetComponent<Interactable>();
playerUI.UpdateText(interactable.promtMessage);
if (inputManager.OnFoot.Interact.triggered)
{
interactable.BaseInteract();
}
}
}
}
}
and here is the refrenced one
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;
// Start is called before the first frame update
void Awake()
{
playerInput = new PlayerInput();
onFoot = playerInput.OnFoot;
motor = GetComponent<PlayerMotor>();
look = GetComponent<PlayerLook>();
onFoot.Jump.performed += ctx => motor.Jump();
}
// Update is called once per frame
void FixedUpdate()
{
motor.ProcessMove(onFoot.Movement.ReadValue<Vector2>());
}
void LateUpdate(){
look.ProcessLook(onFoot.Look.ReadValue<Vector2>());
}
private void OnEnable(){
onFoot.Enable();
}
private void OnDisable(){
onFoot.Disable();
}
}