Join on started room

Options

Hello guys,

I wanted to "fake" persistant rooms. So I have a list of rooms with his names "room 1", "room 2", etc.

When the user clicks on one room I execute this:

PhotonNetwork.JoinOrCreateRoom(roomName, new RoomOptions({MaxPlayers = 16, BroadcastPropsChangeToAll = true}, TypedLobby.Default);

PhotonNetwork.LoadLevel("Game");

And when the user enters on game scene I instantiate his avatar:

GameObject myAvatar= PhotonNetwork.Instantiate(playerToSpawn.name, spawnPoint.position, Quaternion.identity);

The user enters on room without problem, the avatar is instantiated without problem... but, only the first user can move his avatar.

Before, new players could move "a bit" the first instantiated avatar (and this avatar instantly back to his original position) until I put the line:

if (view.IsMine){

Now just the first player can move the first avatar.


But I still have the problem that only the first user/avatar that enters on room can move around the world. It's like all inputs affect just this first avatar.

I hope you could help me. Greetings.

Comments

  • Jaudini
    Options

    Any tip? I have no idea what's happening, I have tried a lot of things.

  • Tobias
    Options

    PhotonNetwork.Instantiate will instantiate the object in all clients. But only the creator of said object will run the code you may have after myAvatar= PhotonNetwork.Instantiate.

    view.IsMine is important for the control, as you can keep the remote player characters from moving due to keypress. But IsMine is only true for the objects you created (called PhotonNetwork.Instantiate).

    I can't really guess why your characters behave as they do but I could give an example of how things should work normally. Read and code along the PUN Basics Tutorial and you should have an idea of how to instantiate and how to control characters.