I’ve been trying to fix this for days and getting nowhere - I’m trying to spawn a blueprinted sublass of ShooterCharacter in the ShooterGameDemo. It just needs to be the Character, it’s not another game ‘player’. The subclassed character is sort of like a bot, but they are created by a player and have a custommovementcomponent that dictates how they move about the level.
When I place a few instances of the Blueprinted class into the level in the editor, everything works as expected. But when I try to Spawn the character mid-game, the Character’s mesh appears, but nothing happens. I can see that the character is being possessed by a controller, and PostInitializeComponents() is being called, but BeginPlay() is not being called.
This is related to the answerhub link below. I’ve run out of things to try, hoping someone here can give me a new route to head down…
ShooterCharacter Constructor:
...
static ConstructorHelpers::FObjectFinder<UBlueprint> BP(TEXT("Blueprint'/Game/GroundGame/Blueprints/BP_EnergyGround.BP_EnergyGround'"));
if (BP.Object) {
ClassToSpawn = (UClass*)tBP.Object->GeneratedClass;
}
...
Spawning code:
...
Spawned = World->SpawnActor<APawn>(ClassToSpawn , GetActorLocation(), GetActorRotation(), SpawnParams);
World->GetAuthGameMode<AShooterGameMode>()->RestartPlayer(Spawned->GetController());
Cast<ACharacter>(SpawnedPickup)->GetCharacterMovement()->SetMovementMode(MOVE_Falling);
...