C++ Blueprint instanciation to load a specifique pawn on connection

Hello every one,

I have started some weeks ago a game project with unreal engine, learning how to use this engine and how achieve my objectives with it.

today I start to hit some trouble that I don’t arrive to solve by my self.

before to speak about my trouble some background arround the project.

this project is based on twin stick template, I have handle to get it playable in multiplayer, after 1 week with the small base pawn of this template I have buy a pack of 7 low poly ship for this game, and created 7 blueprint ship for these one with a parent class in c++

i’m now handling the player spawn when he enter the arena I have success to made it with a temporary blueprint replacing my game mode, and a blueprint for the playerController, but i’m actually in progress to get these one in c++, and try to only use blueprint for my baseActor customisation with only some minimal logic in it.

now the trouble, on the Game mode blueprint I use handle starting player event to spawn a pawn for my player, based on the OptionString (color customisation, models selection, weapon selection …).

here the blueprint: GameModeBP > | PasteBin For Unreal Engine 4

the collapsed node are just a spawn actor with some base property change (like hide the new player to other one until his first move) before to return the BasePawn

and there the cpp file of the gameMode to replace this one:

#include "FreeForAllArenaGameMode.h"
#include "ArenaPlayerController.h"
#include "PawnShipBase.h"

#include "Engine/World.h"
#include "Kismet/GameplayStatics.h"

void AFreeForAllArenaGameMode::HandleStartingNewPlayer_Implementation(APlayerController* NewPlayer)
    UE_LOG(LogTemp, Warning, TEXT("processing New player"));
    // store player controler?
    AArenaPlayerController *ArenaPC = (AArenaPlayerController *) NewPlayer;
    ArenaPC->ShipType = StringToEnum(EShipType, UGameplayStatics::ParseOption(OptionsString, "Shiptype"));
    UWorld *World = GetWorld();
    APawnShipBase *ShipToSpawn = nullptr;
    UClass *ShipClass = nullptr;
    //TODO: switch is fine cause we have not a large list of ship do factory here? else create a private function to store it
    switch (ArenaPC->ShipType)
    case EShipType::Harbinger:
        ShipToSpawn = FindObject<APawnShipBase>(ANY_PACKAGE, TEXT("/Game/Blueprints/ProjectName/Ship/BP_Harbinger.BP_Harbinger"));
        ShipClass = ShipToSpawn->StaticClass();
    case EShipType::Interceptor:
        ShipToSpawn = FindObject<APawnShipBase>(ANY_PACKAGE, TEXT("/Game/Blueprints/ProjectName/Ship/BP_Interceptor.BP_Interceptor"));
        ShipClass = ShipToSpawn->StaticClass();
    case EShipType::Icarus:
        ShipToSpawn = FindObject<APawnShipBase>(ANY_PACKAGE, TEXT("/Game/Blueprints/ProjectName/Ship/BP_Icarus.BP_Icarus"));
        ShipClass = ShipToSpawn->StaticClass();
    case EShipType::Avadora:
        ShipToSpawn = FindObject<APawnShipBase>(ANY_PACKAGE, TEXT("/Game/Blueprints/ProjectName/Ship/BP_Avadora.BP_Avadora"));
        ShipClass = ShipToSpawn->StaticClass();
    case EShipType::ThunderStorm:
        ShipToSpawn = FindObject<APawnShipBase>(ANY_PACKAGE, TEXT("/Game/Blueprints/ProjectName/Ship/BP_ThunderStorm.BP_ThunderStorm"));
        ShipClass = ShipToSpawn->StaticClass();
    case EShipType::Praetor:
        ShipToSpawn = FindObject<APawnShipBase>(ANY_PACKAGE, TEXT("/Game/Blueprints/ProjectName/Ship/BP_Praetor.BP_Praetor"));
        ShipClass = ShipToSpawn->StaticClass();
    case EShipType::Vanquisher:
        ShipToSpawn = FindObject<APawnShipBase>(ANY_PACKAGE, TEXT("/Game/Blueprints/ProjectName/Ship/BP_Vanquisher.BP_Vanquisher"));
        ShipClass = ShipToSpawn->StaticClass();
    AActor *SpawnPoint = FindPlayerStart(ArenaPC);
    //APawnShipBase* pShip = GetWorld()->SpawnActorDeferred<APawnShipBase>(ShipClass, FTransform(FRotator(0, 0, 0), SpawnPoint->GetActorLocation()));
    APawnShipBase* pShip = Cast<APawnShipBase>(UGameplayStatics::BeginDeferredActorSpawnFromClass(ArenaPC, ShipClass, FTransform(FRotator(0, 0, 0), SpawnPoint->GetActorLocation())));
    if (pShip != nullptr) {
        //set color from option here
        pShip->BaseColor.InitFromString(UGameplayStatics::ParseOption(OptionsString, "PrimaryColor"));
        pShip->AdditionalColor.InitFromString(UGameplayStatics::ParseOption(OptionsString, "AdditionalColor"));
        pShip->WindshieldColor.InitFromString(UGameplayStatics::ParseOption(OptionsString, "WindshieldColor"));
        pShip->EnginesColor.InitFromString(UGameplayStatics::ParseOption(OptionsString, "EnginesColor"));
        pShip->WeaponsColor.InitFromString(UGameplayStatics::ParseOption(OptionsString, "WeaponsColor"));
        pShip->JetGlowColor.InitFromString(UGameplayStatics::ParseOption(OptionsString, "JetGlowColor"));
        UGameplayStatics::FinishSpawningActor(pShip, FTransform(FRotator(0, 0, 0), SpawnPoint->GetActorLocation()));

// TODO: event begin play must be call here and init AI (cf GM_FreeForAllArena BP)

my trouble with this way is my BP_pawn constructor are not call, and I have to init some materials on the ship (custom colors), the material binding is not exactly the same on each ship so I can’t setup it in my BaseShip, I’m in search of a way to do it (the ship selection is made from an other level dedicated to the ship customisation.

if some one got a way to achieve it I will be happy to read it.

hello again every one i’m always blocking on this point, all my try finish with the PawnShipBase spawn instead of the blueprint one…, I really don’t know how to handle it.