private float maxDistance = 10.0f; // 최대 거리 void Awake() { state = GetComponent <GuardianState>(); ani = GetComponent <GuardianAnimationCtrl>(); headCtrl = GetComponentInChildren <GuardianHeadCtrl>(); attack = GetComponent <GuardianAttack>(); playerLayer = LayerMask.NameToLayer("Player"); layerMask = 1 << playerLayer; (root = Selector.Make()). AddChild(ActionNode.Make(CheckState)). AddChild(Sequence.Make(). AddChild(ActionNode.Make(SenseFoe)). AddChild(ActionNode.Make(ChecktDistFoe)). AddChild(ActionNode.Make(AttackFoe)). AddChild(ActionNode.Make(CheckFoeDead)) ); }
void Awake() { playerTr = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); sense = GetComponent <BokoblinSense>(); state = GetComponent <BokoblinState>(); attack = GetComponent <BokoblinAttack>(); agent = GetComponent <MoveAgent>(); ani = GetComponent <BokoblinAnimationCtrl>(); uiCtrl = GetComponent <EnemyUICtrl>(); ragdolls = GetComponentsInChildren <Rigidbody>(); foreach (Rigidbody bone in ragdolls) // 시작시 래그돌과 콜라이더를 꺼준다 { if (bone.GetComponent <Rigidbody>() != GetComponent <Rigidbody>()) { if (!bone.CompareTag("Weapon")) { bone.isKinematic = true; bone.GetComponent <Collider>().enabled = false; } } } (root = Selector.Make()). AddChild(ActionNode.Make(CheckState)). // 전투 AddChild(Sequence.Make(). AddChild(ActionNode.Make(IsAlert)). AddChild(ActionNode.Make(CheckMoveToFoe)). AddChild(ActionNode.Make(AttackFoe)). AddChild(ActionNode.Make(CheckFoeDead)) ). // 의심 AddChild(Selector.Make(). AddChild(ActionNode.Make(IsAlert)). AddChild(ActionNode.Make(SenseFoe)) ). // 유휴 AddChild(Selector.Make(). AddChild(ActionNode.Make(IsAlert)). AddChild(ActionNode.Make(Idle)) ); }