Different scenes need different avatars: how do I know when to instantiate?

Options
I have a fairly simple app, based on the Asteroids demo, the 'lobby' interface collects entering users and then Start Game will load the game, next scene. Note that players are already 'in the room'. But when my main scene starts I want to instantiate my avatars for them (different from the lobby), and NOT instantiate too many. I understand that when I instantiate 'my own' avatar, it automatcially instantiates on remotes. How do the remotes get informed of this? Would that be another callback to OnPlayerEnteredRoom? Or do I periodically monitor my scene for the appearance of new avatars, and then deal with them accordingly? I'm looking for a callback or event like 'RemotePlayerHasInstantiated' . Or am I thinking of this all wrong? Please help!

Comments

  • Tobias
    Options
    Put a script on the prefabs of your characters.
    When someone instantiates a prefab, the scripts will run and should know if they are a prefab or not.
    If you want your code to run early, implement IPunInstantiateMagicCallback in any script. It will be called right when the object is instantiated. Careful with referencing stuff that's not setup yet.
  • Dave_A
    Options
    Thanks!