November 2018
Beginner
246 pages
5h 23m
English
This class has three methods: a constructor, a Reason, and an Act.
The code in the PatrolState.cs file is as follows:
using UnityEngine; using System.Collections; public class PatrolState : FSMState { public PatrolState(Transform[] wp) { waypoints = wp; stateID = FSMStateID.Patrolling; curRotSpeed = 1.0f; curSpeed = 100.0f; } public override void Reason(Transform player, Transform npc) { //Check the distance with player tank //When the distance is near, transition to chase state if (Vector3.Distance(npc.position, player.position) <= 300.0f) { Debug.Log("Switch to Chase State"); npc.GetComponent <NPCTankController>().SetTransition( Transition.SawPlayer); } } public override void Act(Transform player, Transform npc) { ...Read now
Unlock full access