Hi!
I’m trying to spawn an actor. In the editor everything works fine, but the game crashes, when I’m launching it. The reason is, that this assertion failes:
check(Stride == TheCppStructOps->GetSize() && PropertiesSize == Stride);
inside this function:
void UScriptStruct::CopyScriptStruct(void* InDest, void const* InSrc, int32 ArrayDim) const
Output Log (see image):
This happens when launching the game for windows and android.
I have a list of subclasses of Waste objects. For testing purposes only one kind of subclass (namely WasteNormal) objects are assigned in this list via the editor.
As I said, in the editor, when pressing play, everything works fine. I wanted to test the game on android and it crashes, as soon as the first actor should be spawned.
My Code (.h):
UPROPERTY(EditAnywhere, Category = "Spawning")
TArray<TSubclassOf<class AWaste>> WasteObjectList;
My Code (.cpp):
void AWasteSpawner::SpawnRandomWaste()
{
UWorld* world = GetWorld();
if (world)
{
ARecyclingGameMode* gameMode = Cast<ARecyclingGameMode>(GetWorld()->GetAuthGameMode());
if (gameMode->GetCurrentState() == EGameStates::PLAYING)
{
int nextRandomIndex = FMath::FRandRange(0, WasteObjectList.Num());
if (WasteObjectList[nextRandomIndex] != NULL)
{
FActorSpawnParameters spawnParams;
spawnParams.Owner = this;
spawnParams.Instigator = Instigator;
/**Random rotation for z-axis*/
FRotator spawnRotator;
spawnRotator.Yaw = FMath::FRand() * 360.0f;
spawnRotator.Pitch = 0.0f;
spawnRotator.Roll = 0.0f;
FVector spawnLoc = SpawnBox->GetComponentLocation();
AWasteNormal* const wasteObject = world->SpawnActor<AWasteNormal>(WasteObjectList[nextRandomIndex], spawnLoc, spawnRotator, spawnParams);
if (wasteObject == nullptr)
{
GEngine->AddOnScreenDebugMessage(-1, 1.00f, FColor::Blue, TEXT("SPAWNING FAILED"));
}
/**Random Spawn Delay*/
m_spawnDelay = FMath::FRandRange(SpawnMinDelay, SpawnMaxDelay);
world->GetTimerManager().SetTimer(SpawnTimerHandle, this, &AWasteSpawner::SpawnRandomWaste, m_spawnDelay);
}
}
}
}
Has anyone an idea, what causes this assertion to fail?