Purpose Of Casting Pawn To Character(From Tutorial)

Hello guys. In this tutorial( this guy gets “player’s pawn” and then casts it to charachter again to be aple to apply velocity. I do not understand why he did not “get player’s character”. Instead he get “player’s pawn”. I tried to get “player’s character” directly and I got same result without casting to character(since I already got my player’s chracter. So I do not understand this unnecesary step.

King Regards.

Id say its just for ease of transition as he talks about the Player as being a Pawn throughout the tutorial. It might have confused some people if he had have just straight up used the GetPlayerCharacter node after talking about a Pawn.

There is no special reason why he did it that way. Both methods are valid.

Maybe GetPlayerCharacter is a later addition, that wasn’t around when the tutorial was first written?

Yes it makes sense jwatte.

One more question: Lets say we cast our pawn to character to use only one specific function and lets say then we create another function something like begin overlap. In this case will our pawn be still character or we should downcast it? I hope I am clear at this point.

If Casting to Character is successful then the “Pawn” is already a SubclassOf Character. Its called Class Inheritance. Character is a child class of Pawn, any functions that a Pawn can perform, is inherited down to a Character. The Character is also technically a Pawn because Pawn is its parent class.

If the Begin Overlap event is specific to Pawn, then Character will have access to it. However if it is specific to Character, then Pawn will not be able to access it unless you Cast to Character first and use the output pin reference as Character.

Thank you for useful information.