Representing Command Data in Unreal Editor for Fortnite
A common pattern in programming is creating a data representation of a concept, like character commands, that you can pass around and treat as data within your code. In this minigame, commands need to be treated as data to generate from the UI interaction and pass to the character to perform.
In this project, a command is represented as an abstract class, and each specific command is a subclass of this command class, such as forward_command and turnright_command. Using an abstract class for the command means that the only valid commands are the subclasses that are not abstract. If you try to create an instance of the command class directly, you'll get an error when you try to compile your code.
Because the character commands are subclasses of the command class, you can use them anywhere the command class is expected, such as the character's ExecuteCommand() function in the previous step. The first parameter in ExecuteCommand() expects the command type, which means you can use an instance of a command subclass as the argument without issue.

You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.