What is the use of cast<typename>

I am here being confused about that cast. Can’t we just include the header file for APlayerController and then create an instance of the class which we can then use in the PawnTank.

Including the header only copies and pastes its contents.

The instance is already created, we’re just getting a pointer to it. The issue is that GetController returns AController* as it is a function on APawn's which can be controlled by either. If the controller is actually an APlayerController then we have a pointer to it otherwise it’ll be nullptr.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms