VR - Swapping Turn Provider & Locomotion Provider from UI

Hello, I’m trying to implement a simple UI that allows users to select their preferred locomotion and turn type. I’m running into an issue where the logic seems to only work when switching from Continuous Move to Teleport. If I try to switch back to Continuous Move it does not work. The same is happening when switching from Continuous Turn to Snap Turn.
Worth noting that Continuous Move and Continuous Turn are both the default values (enabled by default when scene starts), so changing from default setting to another setting works, but reverting to the original setting does not.

I’m using 2 scripts for this, they are attached to the UI menu and the functions to SetActiveFromIndex are called from the respective dropdowns. My scripts attached below… any insights on what I’m doing wrong here?

Movement Script:

public class SetActiveMovementFromDropdown : MonoBehaviour
{
    [SerializeField] DynamicMoveProvider continuousMove;
    [SerializeField] TeleportationProvider teleport;
    [SerializeField] GameObject leftTeleport;
    [SerializeField] GameObject rightTeleport;
    [SerializeField] CharacterControllerDriver driver;



    public void SetActiveFromIndex(int index)
    {
        if (index == 0)
        {
            DisableTeleportation();
            EnableContinousMovement();
        }
        else if (index == 1)
        {
            DisableContinuousMovement();
            EnableTeleportation();
        }
    }

    private void DisableTeleportation()
    {
        leftTeleport.SetActive(false);
        rightTeleport.SetActive(false);
        teleport.enabled = false;
    }

    private void EnableTeleportation()
    {
        leftTeleport.SetActive(true);
        rightTeleport.SetActive(true);
        teleport.enabled = true;
        driver.locomotionProvider = teleport;
    }

    private void DisableContinuousMovement()
    {
        continuousMove.enabled = false;
    }

    private void EnableContinousMovement()
    {
        continuousMove.enabled = true;
        driver.locomotionProvider = continuousMove;
    }
}

Turn Script:

public class SetActiveTurnFromDropdown : MonoBehaviour
{
    [SerializeField] ActionBasedContinuousTurnProvider continuousTurn;
    [SerializeField] ActionBasedSnapTurnProvider snapTurn;

    public void SetActiveFromIndex(int index)
    {
        if(index == 0)
        {
            DisableSnapTurn();
            EnableContinuousTurn();
        }
        else if(index == 1)
        {
            DisableContinuousTurn();
            EnableSnapTurn();
        }
    }

    private void DisableSnapTurn()
    {
        snapTurn.enabled = false;
    }

    private void EnableSnapTurn()
    {
        snapTurn.enabled = true;
    }

    private void DisableContinuousTurn()
    {
        continuousTurn.enabled = false;
    }

    private void EnableContinuousTurn()
    {
        continuousTurn.enabled = true;
    }

}

Hello, in the SetActiveMovementFromDropdown script, when you disable continuous movement, you are not setting the driver.locomotionProvider to null. This means that when you enable continuous movement again, the driver.locomotionProvider still holds a reference to the teleportation provider, causing it to not switch back to continuous movement correctly.
I think you should add a line to set driver.locomotionProvider to null when disabling continuous movement:

csharp
private void DisableContinuousMovement()
{
    continuousMove.enabled = false;
    driver.locomotionProvider = null;
}

Similarly, in the SetActiveTurnFromDropdown script, you need to set the driver.locomotionProvider to null when disabling continuous turn:

csharp
private void DisableContinuousTurn()
{
    continuousTurn.enabled = false;
    driver.locomotionProvider = null;
}

By setting driver.locomotionProvider to null, you ensure that it doesn’t maintain a reference to the previous locomotion provider and correctly switches back to the default setting when enabling it again.

Hope that my answer is useful for you.