Hey all. I’m using the “Basic Code” project template and trying to overload AGameMode
functions such as void StartMatch()
so I can figure out what sorts of events/callbacks drive the gameplay in C++. So far my attempts have been unsuccessful; the overloads never run. Anyone have some pointers on how to get something like this set up?
Thanks.
Dear Paul,
To override StartMatch,
in your own GameMode class:
Here’s the basic code structure
#.h
#include "YourGameMode.generated.h"
UCLASS()
class AYourGameMode : public AGameMode
{
GENERATED_UCLASS_BODY()
public:
virtual void StartMatch() OVERRIDE;
};
#.cpp
#include "YourGame.h"
AYourGameMode::AYourGameMode(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}
void AYourGameMode::StartMatch()
{
Super::StartMatch();
//your additional code here
}
#Config
To make sure you are using your custom Game Mode class:
DefaultGame.ini
[/Script/Engine.WorldInfo]
GlobalDefaultGameType="/Script/YourGame.YourGameMode"
[/Script/Engine.WorldSettings]
GlobalDefaultGameMode="/Script/YourGame.YourGameMode"
GlobalDefaultServerGameMode="/Script/YourGame.YourGameMode"
Enjoy!
Rama
Aha! Interesting, I had no idea I needed to set those game settings. It’s very late here so I’ll give this a whirl tomorrow and let you know how it goes. Thanks
Also, if you have any other resources I can read up on relating to C++ driven gameplay, please share them! The learning curve feels incredibly steep.
I have written 26 tutorials on c++ in UE4 here
http://forums.epicgames.com/threads/972861-26-TUTORIALS-C-for-UE4-gt-gt-New-Toggleable-Rag-Doll-Physics
I have written 15 basic-intro level tutorials here
http://forums.epicgames.com/threads/973803-Tutorials-Entry-Level-UE4-C-Overview-Q-amp-A-gt-Making-Fully-Custom-Camera-Behaviors
If my answer to your question resolves your issue please click the check next to my answer so that others know your issue is resolved
Rama
In newer versions, you can set the default game mode in the project settings in the editor, but this just hasn’t been rolled out to rocket yet.