# Spawning different bot classes in Lyra

**URL:** <https://forums.unrealengine.com/t/spawning-different-bot-classes-in-lyra/2532983>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, LyraStarterGame, question\
**Created:** [May 29, 2025, 4:29pm UTC](https://forums.unrealengine.com/t/spawning-different-bot-classes-in-lyra/2532983 "2025-05-29T16:29:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![awarewoff](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@awarewoff](https://forums.unrealengine.com/u/awarewoff)\
**Post date:** [May 29, 2025, 4:29pm UTC](https://forums.unrealengine.com/t/spawning-different-bot-classes-in-lyra/2532983/1 "2025-05-29T16:29:29Z")

</div>

Hello, wonderful people.  
Has someone tried to spawn a bot of different classes? I mean multiple classes in one experience.  
I kind of did that, but then I found that they don’t have an ability system component, so I can’t apply gameplay effects to them.  
I saw how people spawn different classes for players and bots, but it’s still one bot class for all bots. They just give different PawnData if a pawn is getting spawned for the AI controller. But I need to spawn squads of bots with different classes, strategy style.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/b/d/4bd57e2b78df963f5fa390b83961f16cea0ad034.png)

> **code snippet**
>
> ```auto
> AActor* ULyraBotCreationComponent::SpawnBotOfClass(UClass* Controller, FVector Location, FRotator Rotation, UClass* PawnClass)
> {
> FActorSpawnParameters SpawnInfo; 
> SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
> SpawnInfo.OverrideLevel = GetComponentLevel();
> SpawnInfo.ObjectFlags |= RF_Transient;
> FTransform Transform = FTransform(Rotation, Location);
> AAIController* NewController = GetWorld()->SpawnActor<AAIController>(Controller, Transform, SpawnInfo);
> 
> //creating new pawn. Mimicing GameMode->RestartPlayer, because it can't use specific pawn class
> APawn* NewPawn = nullptr;
> UWorld* World = GetWorld();
> NewPawn = World->SpawnActor<APawn>(PawnClass, Transform, SpawnInfo);
> 
> if (NewController != nullptr)
> {
> ALyraGameMode* GameMode = GetGameMode<ALyraGameMode>();
> check(GameMode);
> 
> if (NewController->PlayerState != nullptr)
> {
> NewController->PlayerState->SetPlayerName(CreateBotName(NewController->PlayerState->GetPlayerId()));
> }
> 
> GameMode->GenericPlayerInitialization(NewController);
> //GameMode->RestartPlayer(NewController); //default implementation from SpawnOneBot, can't use pawn class, so replaced with hardcoded pawn spawn above.
> NewController->SetPawn(NewPawn);
> 
> if (NewController->GetPawn() != nullptr)
> {
> if (ULyraPawnExtensionComponent* PawnExtComponent = NewController->GetPawn()->FindComponentByClass<ULyraPawnExtensionComponent>())
> {
> PawnExtComponent->CheckDefaultInitialization();
> }
> }
> 
> SpawnedBotList.Add(NewController);
> }
> return NewPawn;
> }
> 
> ```
