Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Enemy shouldn't see you through walls

$
0
0
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

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>