's Multiplayer Game Mode Solution
Find Player Start
Choose Player Start
Can Player Restart
These core Multiplayer functions are now fully implementable/overridable in Blueprints![/SIZE]**
I have found a solution for the of implementing FindPlayerStart, ChoosePlayerStart, and CanPlayerRestart in Blueprints!
And I’ve tested it as working!
**You can now implement core network coding of choosing player starts entirely in Blueprints!
**
**How To Use**
In my picture below I show how to use my Game Mode overrides!
1. **First make a new BP and select my VictoryGameMode class** which comes with my Victory BP Library (make sure you have the latest download https://wiki.unrealengine.com/File:VictoryPlugin.zip)
If you already have a Game Mode BP, choose File -> Reparent and use my Victory Game Mode BP
2. Make sure you are using my Victory Game Mode in your **World Settings**!
3. Setup the Victory Game Mode BP the same as my picture below!
4. Celebrate! You can now implement core multiplayer logic in Blueprints!
*(right click -> new tab to see larger pic)*
![VictoryGameMode.jpg|1280x960](upload://1psgB0eeaCt9i59C4zf1sNwPmLm.jpeg)
CPP Override and CPP Override Var
Please note the notation I am using, any variable that has CPPOverride Var in its name is used only with the corresponding event. is how I enable you to implement core multiplayer coding logic in Blueprints!
**Simple Data Types**
Please note that for the function that is designed to return a boolean value, CanPlayerRestart, you must pass the boolean and also a special variable, **CPPOverride SelfReference**, is how you tell the CPP that you are implementing the Game Mode function in BP!
Non Destructive Solution
My solution is entirely optional and if you do not implement the event in Blueprints, and your programmer does it in C++, my solution will not interfere at with your existing code base!
**Log Message**
If you do implement my solution in BP, I am printing log information to indicate , so you/your programmer knows you are using a BP override and any C++ code will not be run.
C++ Code
Here is my C++ code for FindPlayerStart which shows how I worked around the of overriding FindPlayerStart via Blueprints!
Again I’ve tested as entirely working in PIE and commandline games!
.h
//Find Player Start
public:
/** Use var inside the body of CPP Override ~ Find Player Start event to override the C++ functionality! */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Victory Game Mode")
AActor* CPPOverrideVar_FindPlayerStart;
/**
* Use CPPOverrideVar_FindPlayerStart inside of event to implement FindPlayerStart in BP ! <3
*
* Return the 'best' player start for player to start from.
* @param Player - is the AController for whom we are choosing a playerstart
* @param IncomingName - specifies the tag of a Playerstart to use
* @returns Actor chosen as player start (usually a PlayerStart)
*/
UFUNCTION(BlueprintImplementableEvent, meta=(FriendlyName = "CPP Override ~ Find Player Start"))
virtual void CPPOverride_FindPlayerStart();
virtual class AActor* FindPlayerStart( AController* Player, const FString& IncomingName = TEXT("") ) override;
.cpp
//Find
AActor* AVictoryGameMode::FindPlayerStart( AController* Player, const FString& IncomingName )
{
//Clear any previous to indicate whether BP did an override
CPPOverrideVar_FindPlayerStart = NULL;
//=======================
//BP Hook by
->CPPOverride_FindPlayerStart();
//=======================
if(CPPOverrideVar_FindPlayerStart) //Did BP programmer set the var?
{
//Indicate that the BP override was found and is being used.
UE_LOG(VictoryGameModeLog, Log, TEXT("
"));
UE_LOG(VictoryGameModeLog, Log, TEXT("FindPlayerStart: CPP override found in %s and used instead of C++ implementation"), *GetName());
UE_LOG(VictoryGameModeLog, Log, TEXT("
"));
return CPPOverrideVar_FindPlayerStart;
}
//Default C++ Implementation
return Super::FindPlayerStart(Player,IncomingName);
}
**Enjoy!**