Ejemplo n.º 1
0
    public void ProcessMotion()
    {
        // Save MoveVector.z and reapply as VerticalVelocity
        ApplyGravity();

        //Convert Vector to World Space
        Vector3 WorldPosition;

        // If model is inverted then invert Z and Y get world position and revert Z and Y
        if (InvertedModel) {
            MoveVector = MoveVector.InvertYZ ();
            WorldPosition = transform.TransformDirection (MoveVector);
            MoveVector = MoveVector.RevertYZ ();
        } else {
            WorldPosition = transform.TransformDirection (MoveVector);
        }

        float savedY = WorldPosition.y;
        WorldPosition.y = 0;

        float magnitude = WorldPosition.sqrMagnitude;

        //Normalize Vector
        if (magnitude > 1)
            WorldPosition.Normalize();

        WorldPosition = Slide (WorldPosition);

        //Multiply magnifier
        WorldPosition = WorldPosition * SpeedLimit();

        WorldPosition.y = savedY;

        //Convert to unit/second
        WorldPosition *= Time.deltaTime;

        //Move character
        Character_Manager.Instance.CharacterControllerComponent.Move(WorldPosition);
    }