Announcement
Collapse
No announcement yet.
Can't set DefaultPawn in game mode
Collapse
X
-
staticvoidlol repliedIn this case, Object Oriented Programming requires that the DefaultPawnClass is set to a class extended from (and including) Pawn.
Pawn is actually extended from Actor so logically it makes no sense to try and use Actor when the code is expecting a Pawn.
Consider what would happen if you were allowed to do this. What would happen if you called a Pawn-specific function on the Pawn instance when in fact that Pawn is just an Actor?
That Pawn-specific function would not exist. Hence, you can only use classes extended from Pawn, as they will always contain the expected functions and properties.
Leave a comment:
-
nikitablack started a topic Can't set DefaultPawn in game modeCan't set DefaultPawn in game mode
Hello. I've created a player class as AActor. I created a blueprint and set this player as parent class. In game mode class I wrote
Code:static ConstructorHelpers::FObjectFinder<UBlueprint> WarriorActorBPClass(TEXT("Blueprint'/Game/Blueprints/BP_WarriorActor.BP_WarriorActor'")); if (WarriorActorBPClass.Object != NULL) { DefaultPawnClass = (UClass*)WarriorActorBPClass.Object->GeneratedClass; }
Upd.: I changed my default pawn from AActor to ADefaultPawn and now everything works. So what was the problem with Actor? Why can't I setup it as main player?Last edited by nikitablack; 05-13-2014, 06:01 AM.Tags: None
Leave a comment: