Hi, I’m getting errors in unity with
error CS1061: ‘DialogueReader’ does not contain a definition for ‘playerInRange’ and no accessible extension method ‘playerInRange’ accepting a first argument of type ‘DialogueReader’ could be found
playerInRange has the red squiggly line under it.
I’m quite new to coding so it’s pretty confusing.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DetectPlayer : MonoBehaviour
{
public GameObject pressEtoTalkUI;
public DialogueReader reader;
bool playerInField = false;
private void Update()
{
if (!playerInField)
return;
if (!reader.playerInRange)
pressEtoTalkUI.SetActive(true);
else
pressEtoTalkUI.SetActive(false);
if (Input.GetKeyDown(KeyCode.E))
{
reader.playerInRange = true;
}
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
playerInField = true;
}
}
private void OnTriggerExit(Collider other)
{
if (other.CompareTag("Player"))
{
playerInField = false;
reader.playerInRange = false;
}
}
}