- Home /
isVisible not working for AI
I created a script for an AI which is currently behind the player. When the camera looks at AI, it disables a follow script and enables a run script so that the AI runs at the player. It also disables one sound and enables another. I tested it and the isVisible is enabled even when no camera is looking at the AI. Is there any way to fix this
AI Script: {
public AudioSource audioClip;
public AudioSource audioClipdisabled;
//Call every frame
void Update()
{
if (!GetComponent<Renderer>().isVisible)
{
GetComponent<Run>().enabled = true;
GetComponent<AIFollow>().enabled = false;
audioClip.Play();
audioClipdisabled.enabled = false;
Debug.Log ("Seen");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How to make an AI of a car to jump if there is any obstacle 2 Answers
FPS Tutorial AI Damage not Working 1 Answer
Random direction with Mouse Click... 2 Answers
Speed based on Distance 3 Answers