So I’ve read the Multiplayer Quickstart guide in the docs and also this comment that explains the various roles of each class quite nicely. My question is that I’m struggling to connect everything together.
For example, I have no idea how to handle respawning upon death.
AGameModeBase has methods for how respawning should be handled but I have no idea how to trigger a respawn or if I have to implement that logic myself and where that logic would go. One tutorial I followed that used Blueprints set up a chain of custom events to handle respawning but most of the logic is already implemented in
RestartPlayerAtPlayerStart() so I’d assume there’s some way to signal that a player should respawn but I can’t find anything.
Another thing I’m unclear on is how to handle updating values across the various classes like the current game score for each team, kill and death counts etc. From examples I’ve seen on YouTube that use blueprints, custom events are typically used for this but I’m still not sure how events are supposed to be defined and implemented in C++. Any tips or info is welcome.
Good that you’re referring to docs and forum answers, but you have missed the best of them all:
UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf (1.6 MB)
As you said it’s good to use the convenience functions already implemented and not try to reinvent the wheel. The functions you mentioned in GameMode are a great example of what you want. Now how you fire those functions is more of a game design question, but it’s 100% going to happen after a player’s pawn dies. So, you will have the following pipeline in your code:
PawnRecieveDamage()->Health<=0->PawnDead()->Fire X seconds timer and when expired fire RestartPlayer().
All the above logic will happen on server, as it’s all authority stuff.
Custom events in BP are just functions in C++. It’s good to refer to this and this if you’re moving from BP to C++.
Oh man I saw that in Google and glossed right over it. Thank you, I’ll check it out when I’m off work and update the status
I’d first start by swapping over to
AGameMode (subclass of gamemode base). It has multiplayer benefits where
AGameModeBase does not.
That network compendium answered all my questions