Example #1
0
        private void FixedUpdate()
        {
            Vector3 direction = Vector3.zero;

            if (!IsCanMove())
            {
                characterController.SimpleMove(direction);
                return;
            }

//            if (target != null)
//            {
//                direction = (transform.position - target.transform.position).normalized;
//            }

            if (input.IsSomeDirection())
            {
                direction = GetInputDirection();
                direction = direction / direction.magnitude;

                direction *= stats.GetMovementSpeed() * curSpeedMultiplier;

                direction *= GetSpeedByJoystickPushing();

                if (rotating)
                {
                    FaceDirection(direction);
                }
            }

            Move(direction);
        }
Example #2
0
        private void FixedUpdate()
        {
            agent.speed          = stats.GetMovementSpeed() * curSpeedMultiplier;
            agent.updateRotation = rotating;
            if (target != null)
            {
//                FaceTarget();

                agent.SetDestination(target.transform.position);
            }

            if (input.IsSomeDirection())
            {
                Vector3 direction = new Vector3(input.horizontal, 0f, input.vertical);
                direction   = Camera.main.transform.TransformDirection(direction);
                direction.y = 0;
                direction   = direction / direction.magnitude;

                Move(direction);
            }
        }