Announcement

Collapse
No announcement yet.

Delayed spawn, spawn in menu click.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    I've basically accomplished this but it's not beautiful. I traced engine code and couldn't find a good code path where clients, listen servers, and dedicated server have all their player states ready to go at the same time, so there's a bit of hackery involved with the way I'm binding things currently.

    This is the basic idea though without getting too far in the weeds:

    1. PlayerState has an enum of the Class type.
    2. GameMode::GetDefaultPawnClassForController is overridden. If Class enum is ::Unspawned (the default set in PlayerState constructor) it doesn't do anything. If it's anything else in the enum, it uses a lookup table to find the appropriate pawn to spawn.
    3. When client selects the Class it wants, I send it as an RPC to server, which sets it in PlayerState and calls AGameMode::RestartPlayer
    4. In APlayerController::ClientRestart_Implementation both a listen server and normal client have access to the PlayerState finally.

    The Pawn's BeginPlay will have the PlayerState for clients, but on a listen server "client" it is nullptr. OnPossess will only be called on servers, but will have PlayerState available.
    Last edited by zerosum0x0; 04-22-2016, 01:25 AM.

    Leave a comment:


  • started a topic Delayed spawn, spawn in menu click.

    Delayed spawn, spawn in menu click.

    I've been trying to to get delayed spawn to work but when connected as spectator i can't seem to get the engine to allow me to spawn and poses a player.

    Anyone know of any tutorials c++ or blue print that shows the basics of a simple when you connect to a map you stay spectator with a menu where you click to then spawn.

    I've tried binding a button to respawn function that works fine f you've initially spawned but will not work for my first spawn.

    Maybe I should be calling a different type of function, not finding any good examples out there thought I'd finally ask here.
Working...
X