- Home /
Duplicate Question
Weeping angle ai help
im trying to make a weeping angle ai(a ai that only moves if the player arnt looking at it)
but the problem is that i dont how make it make only move if the camera field of view arnt on it. Im thinking too make a field off view float on the player that match the camera field of view and as long as ai is in this field of view it got a bool that is false and cant move or if there is better way to do it (im pretty new to unity too)
this is my update() code and my chase() code that only show how it's actions and it's movement right now, im using navmestagent on my ai too
void Update ()
{
playerDistance = Vector3.Distance(Instance.TheInstance.ThePlayer.transform.position, transform.position);
if (playerDistance < 3f)
{
attack();
}
if (playerDistance < 15f)
{
lookAtPlayer();
}
if (playerDistance < 2f)
{
nav.Stop();
}
if (playerDistance < 12f)
{
if (playerDistance > 2f)
{
chase();
}
}
}
void chase()
{
nav.SetDestination(Instance.TheInstance.ThePlayer.transform.position);
}
How to tell if a camera can see has been covered a number of times. Here is one of those answers:
http://answers.unity3d.com/questions/8003/how-can-i-know-if-a-gameobject-is-seen-by-a-partic.html
If you want to handle the situation where the angle is within the field of view but is hidden by other objects, then you can cast so rays from the corners of the mesh to see if there is anything between the angle and the camera.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
EnemyAI C# Error 1 Answer
AI Look at X axis more efficient code 1 Answer
Need Help making Pong AI beatable 1 Answer