PunTeams? Custom properties? Managing multiple prefabs?

Options
Hey, not sure exactly where to start so I'll try to keep it organized. I heard programmers like that kinda thing, ya? ;P

First, just a quick explanation of what the game involves in relation to this situation:
-Simple 2D game, single scene, single camera
-Two teams of 5
-Each team will start with one ''elite'' and 4 ''lessers''
-The 4 lessers on each team will be able to upgrade into a third character type (lets just call it ''warrior'') in game, and upon death, respawn as a lesser again.

Each of these classes has a separate look, movement, and abilities (obviously?).


What I'm trying to do/need:
In short, I'm trying to create a team selection / character selection / ready up menu. Once everyone in the room has picked a team, a class/character, and clicked "Ready", the masterclient (or anyone or even just an auto countdown) can start the game, and finally everyone gets instantiated with the correct class and on the correct team.

I swear the more I read/study the less I'm understanding. I've resorted to this post as a way to step back and wipe the slate clean if you will and start over with a fresh foundation. I know the menu thing has come up (alot) but either I'm missing something or the specifics aren't quite what I need...


Am I even approaching this correctly??
I can't seem to find anyone that talks about the "correct" way, or a standard/common practice way (or even just A WAY really) to handle this kind of - what should be basic - system of players choosing different characters. All the tutorials and reference material seems to focus on instantiating the same prefab for all players.

My thoughts on how to accomplish this have been:
A. Upon entering room, instantiate an "invisible" player prefab containing only scripts involved with communications to the network and then instantiating and childing the elite / worker prefab to their respective owners after selecting.

B. Create a prefab that has all the different classes movement scripts, sprites[], ect and activate/deactivate the components as needed.

C. Don't bother with an "invisible" player prefab. Since the client is connected, save their team and character selection with PunTeams and custom properties respectively. Then instantiate the specific character/team they've chosen. On start of a new game wipe the custom properties and allow players to reselect their roles (or change teams if necessary).

Some questions:
What is the standard convention of handling something like this?
What exactly "are you" as a connected client before any instantiation?
Where should the script be that handles all this selection? (a gamemanager script in the scene for everyone, or a script on each player/client?)

There are more questions but I think if I can just get over this instantiating selected prefab they will answer themselves. Plus, this post has already become a short novel so I'll end it here...

If you're still reading this thanks a lot! If you didn't want to read that wall of text but still want to help:


TLDR: How do i instantiate different prefabs for different players, while also limiting the max/min number of each class..keeping in mind that these will later be killed and respawned as potentially different prefabs.

Best Answer

Answers

  • fractylan
    Options
    Writing all that down seemed to help alot. I ended up figuring out how to instantiate a selected character type (lol, just setting that string... overthinking it much?)

    I'm still having some trouble with custom properties tho. Will look around on the forums, i'm sure its been answered.
  • fractylan
    Options
    thanks so much for the reply!! - using the OnPhotonPlayersPropertiesChanged() method and some RPCs I was able to cut my code in half while at the same time fixing all the issues I was having AND making the code more robust and easily manipulatable.