Quantcast
Channel: Questions in topic: "realistic"
Viewing all articles
Browse latest Browse all 146

How do I make a cone of vision in raycast? Help!

$
0
0
Hello! I made a script from the vision of the enemy, the "field of vision" that actually worked !, the bad thing is that it is a line and it is very sub-realist, can I do the cone angle vision style? The most realistic enemy vision system. Thank you!! using UnityEngine; using System.Collections; public class EnemyVision : MonoBehaviour { public float Distance; public Transform SightObject; public bool Detected = false; public GameObject Enemy; void Start () { } void Update () { RaycastHit hit; if (Physics.Raycast(SightObject.transform.position, SightObject.transform.forward, out hit, Distance)) { Debug.Log(hit.transform.name); Debug.DrawRay(SightObject.transform.position, SightObject.transform.forward * Distance, Color.green); if (hit.transform.tag == "Player") { Detected = true; Enemy.gameObject.GetComponent().Distancia = Enemy.gameObject.GetComponent().DetectedDistance; Enemy.gameObject.GetComponent().LastDistance = Enemy.gameObject.GetComponent().DetectedLastDistance; } } } }

Viewing all articles
Browse latest Browse all 146

Trending Articles