void Awake() { #if USE_ASTAR Debug.Log("Use Astar!"); #endif aiTransform = GetTransform(); animationStates = aiTransform.GetComponent <AIAnimationStates>(); navMeshAgent = aiTransform.GetComponent <NavMeshAgent>(); objectFinder.CacheTransforms(CachePoint.Awake); InitGlobalTriggers(); if (!useSightTransform || sightTransform == null) { sightTransform = new GameObject("Sight Transform").transform; sightTransform.parent = aiTransform; sightTransform.localRotation = Quaternion.identity; sightTransform.localPosition = eyePosition; useSightTransform = false; } currentDestination = aiTransform.position; SetActive(true); }
public void Update() { if (isActive && Time.timeScale > 0) { objectFinder.CacheTransforms(CachePoint.EveryFrame); if (currentState.RotatesTowardTarget()) { RotateAgent(); } thisPos = aiTransform.position; for (int i = 0; i < triggers.Length; i++) { if (triggers[i].HandleEvaluate(this) && triggers[i].transitionState != null) { currentState = triggers[i].transitionState; } } // If the state remained the same, do the action if (currentState.HandleReason(this)) { currentState.HandleAction(this); } } }
protected virtual void Awake() { objectFinder.CacheTransforms(CachePoint.Awake); for (int i = 0; i < subTriggers.Length; i++) { subTriggers[i].parentTrigger = this; } }
void InitObjectFinder(AIBehaviors fsm) { if (!objectFinder.useCustomTags) { objectFinder = fsm.objectFinder; } else { ownsObjectFinder = true; objectFinder.CacheTransforms(CachePoint.StateChanged); } }
public void HandleInit(AIBehaviors fsm, TaggedObjectFinder parentObjectFinder) { InitializeFinder(fsm); if (!objectFinder.useCustomTags) { objectFinder = parentObjectFinder; } else { ownsObjectFinder = true; } objectFinder.CacheTransforms(CachePoint.StateChanged); Init(fsm); foreach (BaseTrigger subTrigger in subTriggers) { subTrigger.HandleInit(fsm, objectFinder); } }
void Awake() { thisTFM = transform; animationStates = GetComponent <AIAnimationStates>(); navMeshAgent = GetComponent <NavMeshAgent>(); objectFinder.CacheTransforms(CachePoint.Awake); InitGlobalTriggers(); if (!useSightTransform || sightTransform == null) { sightTransform = new GameObject("Sight Transform").transform; sightTransform.parent = thisTFM; sightTransform.localRotation = Quaternion.identity; sightTransform.localPosition = eyePosition; useSightTransform = false; } currentDestination = transform.position; SetActive(true); }
protected virtual void Awake() { objectFinder.CacheTransforms(CachePoint.Awake); }