Casting Explanation

Hello forum,

I’m having some difficulty understanding the purpose of casting such as in the following method from TankPlayerController.cpp.

ATank* ATankPlayerController::GetControlledTank() const
{
return Cast(GetPawn());
}

It’s my understanding that in this case we are converting an APawn to an ATank object in case the caller can only receive ATanks?

If someone could point out what I might be missing if anything, I’d greatly appreciate it.

While we’re on the subject of ATanks, I’ve been wondering what this line from Tank.h does exactly.

public:
// Sets default values for this pawn’s properties
ATank();

Any insight I could glean?

Cheers.

Pretty much, it’ll return a nullptr if the cast fails.

That’s the constructor for the ATank class.