Im trying to make a basic interact function so the player can pick up weapons and interact with doors, but for some reason it gives me an error that says:
"
Severity Code Description Project File Line Suppression State
Error CS1061 ‘object’ does not contain a definition for ‘Interact’ and no accessible extension method ‘Interact’ accepting a first argument of type ‘object’ could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp C:\Users\dylan.walden\Heavy Metal\Assets\Scripts\Player\Player Interact.cs 37 Active "
Here is the code. The error is on the line that says “if (input.OnFoot.Interact.triggered)”
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerInteract : MonoBehaviour
{
private Camera cam;
[SerializeField]
public float distance = 3f;
[SerializeField]
private LayerMask mask;
private PlayerUI ui;
private InputManager input;
void Start()
{
cam = GetComponent().cam;
ui = GetComponent();
input = GetComponent();
}
void Update()
{
ui.UpdateText(string.Empty);
Ray ray = new Ray(cam.transform.position, cam.transform.forward);
Debug.DrawRay(ray.origin, ray.direction * distance);
RaycastHit hitInfo; //stores collision data for ray
if(Physics.Raycast(ray, out hitInfo, distance, mask))
{
if (hitInfo.collider.GetComponent() != null)
{
InteractBase interact = hitInfo.collider.GetComponent();
ui.UpdateText(interact.promptMessage);
if (input.OnFoot.Interact.triggered)
{
}
//only use the line below to see if things are working right
//Debug.Log(hitInfo.collider.GetComponent().promptMessage);
}
}
}
}
Does anyone know what I can do to fix this? I have the action set in the input manager and it has binds and everything, so that isn’t the issue. I just don’t know what to do.