Planning for C++
- Roland Thomas

- Oct 20, 2023
- 3 min read
Updated: Nov 23, 2023
One of my project aims is to increase my comfortability with using C++ in Unreal Engine. To help achieve this, I spent a lot of time trying to identify which parts or features of Nemesis: Showdown could be coded in C++ that would be feasible for the scope, reasonable for the game, and not too complicated for me to be able to learn and implement.
I had done plenty of prior research on the differences and comparisons between Blueprints & C++, so I knew that some Blueprint nodes are more taxing on memory than others, and also that Blueprints are typically used over C++ when dealing with visual aspects of the game, such as animations, etc. Some of the more memory-expensive blueprint nodes are the networking ones for online multiplayer, so C++ is known to be the ideal way to create a multiplayer game in Unreal Engine, however it's also known to be notoriously difficult. As I have not made an online game before, I decided coding the multiplayer features in C++ would be too much for me at this time, so I would implement them as efficiently as I can in blueprints.
Whilst I'm prepared to build the bulk of my game in blueprints, I'm happy to move certain aspects to C++ if I have the time.
One area I identified as a worthy feature to implement in C++ is the Game Manager features. This includes keeping track of the current Paradigm values (Hope/Despair), Match time, player score, etc. It would be a relatively simple script I'm sure, but a good one to help remind me of Unreal's naming conventions & syntax, and a good way for me to learn how to expose that information to blueprints for use in other parts of the game, as well as getting something to work in C++ that I can build on.
After doing research I began to create the C++ for this. To start with, what base class should it derive from? Thinking of the Unity workflow from previous projects, I looked to create an empty actor that I would place in the level, and have the Game Manager C++ script on that. I created variables for Hope & Despair, making the values accessible in blueprints, as well as functions to increment one of the values, which would then decrement the opposite paradigm value.



After successfully creating the C++ actor and placing it in the level, I started rethinking how I would implement the Game Manager. An actor placed in a level would be instantiated on that level only, but since it would also need to be synced with the opponent, where should the Game Manager information go so that the correct information is synced correctly?
I did some more research on this, and found that the answer was very much different if I was making a single player game than an online multiplayer one. If it was a single player game, I could put the game manager info anywhere I want that works. A Game Instance class would be perfect for it then, for example. However, because my game is multiplayer, I need to take into account Client & Server relationships, and what information Replicates where. I found that in Unreal, things like that would be handled in a Game Mode class. So looked into what it takes to create a C++ script for that.
After doing a deep dive into how Unreal used different classes to manage information in multiplayer games, how those classes relate to each other and how they relate to Server/Client instances, I realised that what I had planned to have in my Game Manager actor was actually going to need to be spread across different classes, such as a Game Mode, Game State, Player State, etc. Configuring these, the RPCs required, ensuring required variable are shared across classes as necessary as well as ensuring that the correct information replicates correctly would be too much for me to configure in C++ at this stage , so I made the decision to implement this in Blueprints. I will find another feature to implement in C++ in the future.
For now, lots more research into setting up multiplayer, replication etc, then designing & planning what information which be held in what class, and how I want the information to relate and communicate with each other so N:S works the way I imagined.


Comments