Hi,
How would I access my my custom player controller from my character class? In some peoples code I’ve seen people use something like this CPC->GetControlRotation(); for example. Where I assume CPC is the stored name for their CustomPlayerController. But without the rest of their code I can’t see how they actually access the controller.
Thanks,
Jack
GetController() returns controller that currently possessing the pawn, either AI or player controller:
If pawn is not possesed it will return nullptr, so do a check before starting doing calls to player controller
Here is some code to get you started.
You can simply declare variables in header if you do not want to repeatedly refer the variables.
You can initialize the variable like this. As @anonymous_user_f5a50610 mentioned, if your character is not posessed by an AI /Player, it will return null. As for the following code, the first posessed pawn/character is saved. Following does this in BeginPlay.
The following code uses that reference to do some fancy headbobs. Camera transitions should work similarly. Commented out because, well, headbobs.
WW_Player here, is a first person C++ only class, derives from character class and automatically generated by a custom GameModeBase.
This seems to get my player controller but not my custom player control. I need to run a function from my custom one from the character class input component.
Is the game starting up using a GameMode that assigns your custom Player Controller by default? If not, are you explicitly telling to create and assign your custom controller to each player?