Example #1
0
    /// <summary>
    /// 상태에 있는 동안 설정한 주기마다 실행되는 Update함수
    /// </summary>
    public override void Execute()
    {
        //대상이 없으면 다시 Wander로 보내주기
        if (!Owner.IsFindTarget)
        {
            SuperFSM.ChangeState <Wander>();
        }

        //Chase 대상을 쫓는 기능 - StoppingDistance 안쓰고 바로 상태전이 해도 됨.
        float     stoppingDistance = 0.5f;
        Transform targetTransform  = Owner.NearFindPlayer.player.transform;
        Vector3   dir     = (targetTransform.position - Owner.transform.position).normalized;
        Vector3   destPos = targetTransform.position - dir * stoppingDistance;

        float distance = Vector3.Distance(targetTransform.position, Owner.transform.position);

        Debug.Log(distance);
        Owner._navMeshAgent.destination = destPos;

        //Owner._navMeshAgent.destination = Owner.NearFindPlayer.player.transform.position;

        //Chase 거리에 따라 Attack으로 상태 전이
        if (Owner._navMeshAgent.remainingDistance <= stoppingDistance)
        {
            SuperFSM.ChangeState <Attack>();
        }
    }
Example #2
0
    /// <summary>
    /// 상태에 있는 동안 설정한 주기마다 실행되는 Update함수
    /// </summary>
    public override void Execute()
    {
        if (Owner._navMeshAgent.remainingDistance <= 0.5f)
        {
            Owner.curWanderIndex =
                (int)Mathf.Repeat(SuperFSM.owner.curWanderIndex + 1,
                                  SuperFSM.owner.wanderPoints.Length);
            Owner._navMeshAgent.destination = Owner.CurrentWanderPoint;
        }

        //ChangeChaseState
        if (Owner.IsFindTarget)
        {
            SuperFSM.ChangeState <Chase>();
        }
    }