- Home /
My collisions doesn't detect the collider's tag
I am making a survival horror game and am having some issues with my AI not detecting a collider that is awoken that doesn't update the Navmesh agent with a new position. Things I have tried, rapidly reseting my colliders, using the collider stay method and playing around with my collider settings. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI;
public class AISearch : MonoBehaviour
{
public Transform target;
public GameObject targetPlayer;
NavMeshAgent agent;
public Transform juke;
public Transform juke1;
public Transform juke2;
public Transform juke3;
public Transform juke4;
public Transform juke5;
public Transform juke6;
public Transform juke7;
public Transform juke8;
public bool onOff = false;
// Start is called before the first frame update
void Start()
{
agent = GetComponent<NavMeshAgent>();
agent.SetDestination(target.position);
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
Destroy(targetPlayer);
Debug.Log("Game Over");
}
if (other.gameObject.CompareTag("Collision"))
{
agent.SetDestination(juke.position);
}
if (other.gameObject.CompareTag("Collision1"))
{
agent.SetDestination(juke1.position);
}
if (other.gameObject.CompareTag("Collision2"))
{
agent.SetDestination(juke2.position);
}
if (other.gameObject.CompareTag("Collision3"))
{
agent.SetDestination(juke3.position);
}
if (other.gameObject.CompareTag("Collision4"))
{
agent.SetDestination(juke4.position);
}
if (other.gameObject.CompareTag("Collision5"))
{
agent.SetDestination(juke5.position);
}
if (other.gameObject.CompareTag("Collision6"))
{
agent.SetDestination(juke6.position);
}
if (other.gameObject.CompareTag("Collision7"))
{
agent.SetDestination(juke7.position);
}
if (other.gameObject.CompareTag("Collision8"))
{
agent.SetDestination(juke8.position);
}
if (other.gameObject.CompareTag("Sneak"))
{
agent.SetDestination(target.position);
}
if (other.gameObject.CompareTag("Run"))
{
agent.SetDestination(target.position);
}
}
Are you using Colliders or Triggers?
When you use Trigger functions the colliders must be switched to triggers.
Check that may be that will help.
They are all triggers (except for the player which works fine) and because of how I have it set up they have to stay that way, I also tried setting the main enemy listener collider to a non trigger but that seemed to glitch it out even more.
If you just want to detect the collider, you can use Raycast.
Your answer
Follow this Question
Related Questions
NavMeshAgent with Collision - Need Help 1 Answer
Moving NavMeshAgent inside a Collider 2 Answers
Enemies using navmesh are bumping each other through solid objects 1 Answer
Need help with fixing position of Colliders for a Ragdoll 1 Answer
OnMouseDown not firing if character isn't touching ground 0 Answers