コード例 #1
0
 private void ChangeAnimStateIfNeeded(AnimatorPoseState newPoseState)
 {
     //if (newPoseState == _currentState) {
     //    return;
     //}
     _animator.SetInteger("PoseState", (int)newPoseState);
     _currentState = newPoseState;
 }
コード例 #2
0
            public CharacterController(NavMeshAgent characterNavMeshAgent, Animator characterAnimator)
            {
                _navMeshAgent              = characterNavMeshAgent;
                _navMeshAgent.speed        = 0.01f;
                _navMeshAgent.angularSpeed = 90.0f;
                _navMeshAgent.acceleration = 4.0f;
                _navMeshAgent.autoBraking  = true;
                _navMeshAgent.radius       = 0.5f;
                _navMeshAgent.height       = 1f;

                _animator     = characterAnimator;
                _currentState = AnimatorPoseState.Stay;
            }
コード例 #3
0
            private void Move(float forwardRate, AnimatorPoseState animState)
            {
                if (_navMeshAgent == null)
                {
                    print("_navMeshAgent is null");
                }

                print(_navMeshAgent.pathStatus != NavMeshPathStatus.PathInvalid);
                print(_navMeshAgent.isOnNavMesh);


                //this.ChangeAnimStateIfNeeded(animState);
                if (forwardRate == 0f)
                {
                    return;
                }
                var offset = new Vector3(0f, 0f, forwardRate * _characterVelocity * Time.deltaTime);

                //_navMeshAgent.gameObject.transform.Translate(offset);
                _navMeshAgent.enabled = true;
                _navMeshAgent.Move(offset);
            }