I have this script which is supposed to disable or enable a NavMeshLink component whenever a bool called “open” in a gate script is set to true or false, but the editor doesn’t recognize the NavMeshLink type in the script. Also, when I tried to separate the enabling and disabling of the NavMeshLink, it returned an error saying that I cannot enable or disable a component the way that I was trying. Is there anyway that I can get this script to work so that it recognizes the NavMeshLink type and according enables or disables the NavMeshLink component?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class GateToggle : MonoBehaviour
{
[Header("References")]
public Gate gate;
public NavMeshLink link;
private void Update()
{
if (link != null && gate != null)
{
link.enabled = gate.open;
}
else if (link != null && gate == null)
{
link.enabled = true;
}
}
}