Esempio n. 1
0
 private void UpdateAnimations(float distanceToTarget)
 {
     if (moveSpeed > 0.01f)
     {
         if (distanceToTarget <= characterController.radius * 2)
         {
             SetAnimation(AnimationName.Idle);
         }
         else
         {
             SetAnimation(DefaultAnimationController.GetAnimationName(Vector3.forward, playerSpeed));
         }
     }
     else
     {
         if (inputController.GetBool(GMKeyCode.Hidden))
         {
             SetAnimation(AnimationName.CrouchIdle);
         }
         else
         {
             SetAnimation(AnimationName.Idle);
         }
     }
 }
Esempio n. 2
0
            private void UpdateAnimations()
            {
                if (!grounded)
                {
                    SetAnimation(AnimationName.RunJump);
                    return;
                }

                if (moveSpeed > 0.01)
                {
                    if (gameEntity.IsNpc())
                    {
                        SetAnimation(AnimationName.Run);
                    }
                    else if (controllingBoat)
                    {
                        SetAnimation(AnimationName.Idle);
                    }
                    else if (swimming)
                    {
                        SetAnimation(AnimationName.Swim);
                    }
                    else
                    {
                        if ((inputController.GetBool(GMKeyCode.MouseRight)) && inputX != 0)
                        {
                            if (inputX < 0)
                            {
                                SetAnimation(DefaultAnimationController.GetAnimationName(Vector3.left, playerSpeed));
                            }
                            else
                            {
                                SetAnimation(DefaultAnimationController.GetAnimationName(Vector3.right, playerSpeed));
                            }
                        }
                        else
                        {
                            if (inputY > 0)
                            {
                                SetAnimation(DefaultAnimationController.GetAnimationName(Vector3.forward, playerSpeed));
                            }
                            else if (inputY < 0)
                            {
                                SetAnimation(DefaultAnimationController.GetAnimationName(Vector3.back, playerSpeed));
                            }
                        }
                    }
                }
                else
                {
                    if (swimming)
                    {
                        SetAnimation(AnimationName.SwimIdle);
                    }
                    else
                    {
                        if (inputController.GetBool(GMKeyCode.Hidden))
                        {
                            SetAnimation(AnimationName.CrouchIdle);
                        }
                        else
                        {
                            if (gameEntity.IsInCombat())
                            {
                                SetAnimation(AnimationName.IdleCombat);
                            }
                            else
                            {
                                SetAnimation(AnimationName.Idle);
                            }
                        }
                    }
                }
            }
Esempio n. 3
0
            private void AgentUpdate()
            {
                if (gameEntity.IsDead())
                {
                    SetAnimation(AnimationName.Dead);
                    return;
                }

                if (agentTarget == Vector3.zero)
                {
                    return;
                }



                if (playerSpeed == 0f)
                {
                    agent.speed        = walkSpeed;
                    agent.acceleration = walkSpeed + 1f;
                    speed = walkSpeed;
                }
                else
                {
                    agent.speed        = runSpeed;
                    agent.acceleration = runSpeed + 1f;
                    speed = runSpeed;
                }

                agent.acceleration = speed;

                moveSpeed    = (transform.position - lastPosition).magnitude;
                lastPosition = transform.position;

                if (moveSpeed > 0.01f)
                {
                    agent.updateRotation = true;
                    SetAnimation(DefaultAnimationController.GetAnimationName(Vector3.forward, playerSpeed));
                }
                else
                {
                    if (targetTransform != null)
                    {
                        agent.updateRotation = false;
                        Vector3 dir = (targetTransform.position - transform.position);
                        RotateTowards(dir);
                    }
                    else
                    {
                        agent.updateRotation = true;
                    }
                    SetAnimation(AnimationName.Idle);
                }



                if (updateAgentDestination)
                {
                    agent.SetDestination(agentTarget);
                    updateAgentDestination = false;
                }
            }