Trouble with cursor

Gilsdank
Gilsdank
edited December 2018 in Photon Bolt
I am creating a UI and everything works great on the server player. However when the client goes into the UI the cursor does not unlock and become visible.

Has anyone else had this issue? I am at a loss.

Edit: I should add that when the client attempts to open the menu, the ui elements pop up like normal but no lose control. This also causes the server players ui to break.

Comments

  • MasonEntrican
    edited December 2018
    Im having the same issue actually. Here are my steps to compare

    1) Bolt entity Player prefab is instantiated through tutorial provided PlayerObject and PlayerObjectRegistry
    2) Player prefab has a PlayerController script with an enum state machine

    public enum uiStateMachine
    {
    _none,
    _inventory,
    _paused
    }

    public uiStateMachine uiState;

    3) The PlayerController then has a function to determine what to do with the cursor based on uiStateMachine

    public void UpdateCursor()
    {
    switch (uiState)
    {
    case uiStateMachine._none:
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
    break;
    case uiStateMachine._inventory:
    Cursor.lockState = CursorLockMode.None;
    Cursor.visible = true;
    break;
    default:
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
    break;
    }
    }

    4) UI singleton prefab gets instantiated and the correct player entity reference within PlayerCallbacks.cs : SceneLoadLocalDone() and ControlOfEntityGained() respectively

    UIController.Instantiate();
    UIController.instance.SetPlayer(entity);

    5) Everytime the KeyDown on local game instance is hit, the enum is changed accordingly and UpdateCursor() is called. Ive tried bolt commands to handle this input aswell but no reason to have the server send messages just to open a local inventory for now.

    Now when i only run a single server this works fine. However when a client connects everything breaks with no errors. Through debugging whats happening here is that the enum state machine is properly setting and staying independent. However the Cursor.lockState and Cursor.visible values are changing once a client connects (which the client does on attach so to set the default cursor state). The server values then change when the client changes its cursor state, however Cursor.visible no longer functions at all.

    Please help lol. I feel like Cursor visibility is a problem someones already solved or bolt has addressed.
  • I have done that actually but thank you. Ive made some progress and it turns out my player script wasnt referencing the UIController properly. I now have a SetUiReferences void in the UIController thats called by PlayerCallbacks and sets the proper references to the player. For some reason a simple entity.IsOwner wouldnt do it. Now to find out why the server cant find the reference but still calls that very reference it throws the error about lol.