I want to create objects and then destroy them, but I cannot save the created objects to the queue.
TQueue <AActor*> que = TQueue <AActor*>();
void AMyProjectCharacter::Spawn()
{
if (ToSpawn)
{
UWorld* world = GetWorld();
if (world)
{
FActorSpawnParameters spawnParams;
spawnParams.Owner = this;
FRotator rotator;
for (int i = 0; i < 100; i++)
{
FVector spawnLocation = FVector(FMath::RandRange(0, 10000), FMath::RandRange(0, 10000), FMath::RandRange(0, 10000));
AActor* actor = world->SpawnActor<AActor>(ToSpawn, spawnLocation, rotator, spawnParams);
que.Enqueue(actor);
}
}
}
}
void AMyProjectCharacter::Despawn()
{
while (que.IsEmpty == false)
{
AActor a = que.Dequeue;
a.Destroy();
}
}
I get compilation errors.
*Building MyProjectEditor…
Using Visual Studio 2019 14.24.28314 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Building 4 actions with 6 processes…
[1/4] MyProjectCharacter.cpp
E:\Unreal Projects\MyProject\Source\MyProject\MyProjectCharacter.cpp(87) : error C2280: “TQueue<AActor *,EQueueMode::Spsc>::TQueue(const TQueue<AActor *,EQueueMode::Spsc> &)”: ?।?ਭ??? ???⪠ ??뫪? ?? 㤠??? ?㭪???
E:\Programs\Unreal Engine 4.23\UE_4.24\Engine\Source\Runtime\Core\Public\Containers/Queue.h(293): note: ??. ?????? “TQueue<AActor *,EQueueMode::Spsc>::TQueue”
E:\Programs\Unreal Engine 4.23\UE_4.24\Engine\Source\Runtime\Core\Public\Containers/Queue.h(293): note: “TQueue<AActor *,EQueueMode::Spsc>::TQueue(const TQueue<AActor *,EQueueMode::Spsc> &)”: ?㭪??? ? 㤠???.
E:\Unreal Projects\MyProject\Source\MyProject\MyProjectCharacter.cpp(114) : error C3867: “TQueue<AActor *,EQueueMode::Spsc>::IsEmpty”: ???⠭??? ᨭ⠪???; ?ᯮ??? “&”, ?⮡? ᮧ??? 㪠??⥫? ?? 童?
E:\Unreal Projects\MyProject\Source\MyProject\MyProjectCharacter.cpp(116) : error C3867: "TQueue<AActor ,EQueueMode::Spsc>::Dequeue": ???⠭??? ᨭ⠪???; ?ᯮ??? “&”, ?⮡? ᮧ??? 㪠??⥫? ?? 童?