x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Only after launch; Game crashes, when spawning actor (Assertion failed)

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): alt text

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.

alt text

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?

Product Version: UE 4.21
Tags:
more ▼

asked Jan 08 '19 at 08:20 AM in C++ Programming

avatar image

Undianer
10 1 1 3

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

I found the reason for it! I had broken materials on the actors that should get spawned. I removed them and now everything works. Thanks to everyone, who tried to help.

more ▼

answered Jan 08 '19 at 02:34 PM

avatar image

Undianer
10 1 1 3

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question