Input Authority

Hello Ramon, how are you doing? We're having a problem here with InputAuthority, I was hoping you could help us.

In our game Eo, we have Dungeon Masters around the players and they need to be able to "Possess" NPCs, so they're always jumping from one NPC to the other to talk to players. So, in our NetworkPlayer, we have a method like this:

  public void Possess(PlayerRef player, NetworkPlayer oldPlayer)
    {
        Local = this;
        Camera.main.GetComponent<CameraScript>().target = transform;
        //Enable new input and disable old one
        SpawnManager.SetCharacterInput(characterInputHandler);
        GetComponent<CharacterInputHandler>().enabled = true;
        oldPlayer.GetComponent<CharacterInputHandler>().enabled = false;
        SpawnManager.RPC_AlertDMs(oldPlayer.name + " possessed " + pcName);
        Object.AssignInputAuthority(player);
        oldPlayer.Object.RemoveInputAuthority();
       // SpawnManager.Despawn(oldPlayer);
    }

Seemed pretty straight forward to me, but we're failing here. If I comment the line oldPlayer.Object.RemoveInputAuthority() then it works but the Dungeon Master is moving both NPCs now, the one he possessed and the one he came from. The thing is, if we use the oldPlayer.Object.RemoveInputAuthority() line, something happens and the DM loses authority completely for both NPCs. Do you know what we're doing wrong here?

All the best,

Rafael at www.firegamestudios.com

Comments