示例#1
0
    void FixedUpdate()
    {
        var dt = Time.fixedDeltaTime;

        if (_teleporting)
        {
            _teleporting       = false;
            _movement.Position = _teleportPosition;
        }

        PreviousVelocity = Velocity;

        if (!IsKinematic)
        {
            Velocity += _manager.Gravity * dt;
            var damping = _manager.GetDamping(IsGrounded);
            if (damping > 0f)
            {
                Velocity *= Mathf.Exp(-damping * dt);
            }
        }

        OnMoving();

        //_movement.Move((PreviousVelocity + Velocity)*dt/2f);
        _movement.Move(Velocity * dt);
        UpdateGrounded();
        CheckCollisions();
    }