November 2018
Beginner
246 pages
5h 23m
English
The sight sense detects whether a specific aspect is within the perception field of the character. If it perceives anything, it takes the specified action.
The code in the Sight.cs file is as follows:
using UnityEngine; public class Sight: Sense { public int FieldOfView = 45; public int ViewDistance = 100; private Transform playerTrans; private Vector3 rayDirection; protected override void Initialize() { //Find player position playerTrans = GameObject.FindGameObjectWithTag("Player").transform; } // Update is called once per frame protected override void UpdateSense() { elapsedTime += Time.deltaTime; // Detect perspective sense if within the detection rate if (elapsedTime >= detectionRate) DetectAspect(); } //Detect perspective field ...Read now
Unlock full access