How Unreal works
As you know, Unreal manages several implementations of the same base classes to define a common framework. Then, each developer must create child classes from those that the engine can offer to perform tasks in the Engine.
In this case, it is about the InputComponent, which is used to process user input, interprets it and passes it along with the controllers and / or, subsequently, pawns.
For example, if you want to define elements such as Pawns, PlayerControllers, AIControllers, HUD, etc., you do it in GameMode, then you configure it in the project settings or, directly, to a level through World Settings (in case your level requires a specific GameMode). These links are also classes that Engine will create at the time of the installation of the game.
Here goes the error
Given this, here comes the flip side. In UE4 C ++ (yes, this is the thing!), Since the engine binds the free ends, sometimes you wonβt be able to use certain classes because they are not declared. Of course, you can include them, but think about it: how many circular dependencies will be created if you make all the inclusions that you need for one class, only to find another can indirectly require one?
Solution Forward declaration . This case, however, is a special flavor called an abbreviated forward declaration in which you declare a type in the place where you use the class.
This is very convenient if you just use it once, so at the beginning of the file you will not get a terrible list of ads.
Bringing it to the real world
For example, if you want to know the current Pawn class by default, you can check the public variable GetDefaultPawnClass in your GameMode (let it be MyGameMode ). A variable is defined as follows:
TSubclassOf < APawn > DefaultPawnClass
See what TSubclassOf ? This is actually a class template for type safety. This is actually a hint of an editor to show you only classes derived from APawn .
If you use a custom type and build on what I have discussed so far, you can find things like this:
TSubclassOf<class ASpeedyPawn> MySpeedyPawn;