Hi folks,
I am using Javascript and this is my script I have for now attached to my enemy.
var Target : Transform;
function Start ()
{
Target = GameObject.FindGameObjectWithTag("Player").transform;
}
function Update ()
{
var distance : float = Vector3.Distance(Target.position, transform.position);
var targetDir = Target.position - transform.position;
var forward = transform.forward;
var angle = Vector3.Angle(targetDir, forward);
if (angle < 45.0)
{
Debug.Log("Can see player");
}
}
Well the problem is, the enemy can see through walls what is not supposed to be.
How can I make the enemy can't see you through walls?
Someone who can help me please? I am struggling now for days..
Thanks in advance
↧