Don't spawn until button click

Vlaxep

Active member
Just starting out with the Opsive Add-On PUN kit.

I want players to join the room and be presented with a menu, where they might choose some options and choose character class/appearance/loadout etc.

Only then can they click a 'Spawn' button and their character is spawned in.

Is there already a feature like this?

I've looked through SpawnManagerBase and it seems like it's only set up to spawn in a 'newplayer' upon Entering the room - I'm thinking even if I stop this from happening, and call SpawnPlayer() later, it won't recognise them as 'the new player that just entered the room' and it wont work.
 
Update:

So I'm wondering about this solution to player character selection.... I can successfully do the following (in a single player game so far)....

- Destroy Character Object AND Main Camera Object
- Instantiate New Character Object Prefab AND Main Camera Object Prefab

This seems to work a treat, is there any downside to this? Will it cause issues in PUN?

My goal here is to have players choose a class/character which basically instantiates that prefab and gives them control of it.They'll choose this character/class either from a Menu or possibly whilst using a kind of 'Recruit' class of character, before choosing another class.

The transition could be immediate or I could potentially bridge it with some nicer transition before destroying the Main Camera, but that's all stuff I can do later.

My main question is whether this is viable for PUN Multiplayer and do I need to do anything extra on top of this to make sure all Clients will see the the newly instantiated character and their items correctly?
 
Oooh so this doesn't work on a Prefab Character with all the PUN Components...

The Camera and Character spawn in buuuut, the character's NetworkCharacterlocomotionHandler and UltimateCharacterLocomotion do not start as Active.

Result is that it seems that Camera is in the right position, character is there, but no weapons are equipped and can't be changed to, despite them being in the ItemSets and Inventory.

I think this will work if I can get the weapons to equip properly, anyone have an idea?
 
Last edited:
Is there already a feature like this?
No, that is a not a built-in feature.

- Destroy Character Object AND Main Camera Object
- Instantiate New Character Object Prefab AND Main Camera Object Prefab
I would not approach it this way as that is a lot of unnecessary work.

The SpawnManagerBase is responsible for spawning the character. By default it spawns the character when the client is finished loading. You could modify this class (or create a new one) which spawns the character when a button is pressed.
 
Top