Using the Sense class
The Sense
class is the interface of our sensory system that the other custom senses can implement. It defines two virtual methods, Initialize
and UpdateSense
, which will be implemented in custom senses, and are executed from the Start
and Update
methods, respectively.
Note
Virtual methods are methods that can be overridden using the override
modifier in derived classes. Unlike abstract
classes, virtual classes do not require that you override them.
The code in the Sense.cs
file looks like this:
using UnityEngine; public class Sense : MonoBehaviour { public bool enableDebug = true; public Aspect.AspectTypes aspectName = Aspect.AspectTypes.ENEMY; public float detectionRate = 1.0f; protected float elapsedTime = 0.0f; protected virtual void Initialize() { } protected virtual void UpdateSense() { } // Use this for initialization void Start () { elapsedTime = 0.0f; Initialize(); } // Update is called once per frame void Update () ...