Hey. I am creating a cycle that must pass through the array and create Astor, but he does not want to work! I served on the function and the input BeginPlay parametn I feed an array of structures that con Also I look how many elements in a loop through and it shows the correct amount of (3), and the cycle goes first element and stops. What could be the problem? Thank you. P.S.
A Blueprint everything works fine, but there is no C ++
TArray<AStorageItem*> UStorageComponent::CreateItems(TArray<FST_BeginItemInfo> &Structure)
{
TArray<AStorageItem*> CreatedItems;
if (Structure.Num() > 0)
{
for (int32 i = 0; Structure.Num() > i; i++)
{
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString::FromInt(i));
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString::FromInt(Structure.Num()));
if (CheckIftemCanBeCreated(Structure[i].ItemClass, Structure[i].Count))
{
UWorld* const World = GetWorld();
if (World)
{
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = GetOwner();
SpawnParams.Instigator = UGameplayStatics::GetPlayerPawn(this, 0);
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
FVector SpawnLocation = FVector(0.f, 0.f, 0.f);
FRotator SpawnRotation;
SpawnRotation.Yaw = 0.f;
SpawnRotation.Pitch = 0.f;
SpawnRotation.Roll = 0.f;
AStorageItem* ItemSpawn = World->SpawnActor<AStorageItem>(Structure[i].ItemClass, SpawnLocation, SpawnRotation, SpawnParams);
AddItem(ItemSpawn, this);
CreatedItems.Add(ItemSpawn);
return CreatedItems;
}
return CreatedItems;
}
}
return CreatedItems;
}
return CreatedItems;
}