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"

Why i have error the spawn actor?

i try spawn from GameInstance.

GameInstance cpp:

     static ConstructorHelpers::FClassFinder<AGameObject> Character(TEXT("/Game/Blueprints/Game/BP_Object"));
     if (Character.Class != NULL)
         GameObject = Character.Class;
 void UMyGameInstance::SpawnObjectsFromArray()
 UWorld* const World = GetWorld();
     if (World)
         const FVector& Location = FVector(0.0f, 0.0f, 148.0f);
         const FRotator& Rotation = FRotator();
         FActorSpawnParameters SpawnParams;
         World->SpawnActor<AActor>(GameObject, Location, Rotation, SpawnParams);

GameInstance h:

     TSubclassOf<class AGameObject> GameObject;

After launch the game i have error window. alt text

Product Version: UE 4.12
screenshot_3.png (921.5 kB)
more ▼

asked Jun 02 '16 at 11:19 AM in C++ Programming

avatar image

7 2 2 3

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

1 answer: sort voted first

Try checking for Null and switch from AActor to AGameObject as template

 World->SpawnActor<AGameObject>(GameObject->GetClass(), Location, Rotation, SpawnParams);

Also set the Rotator to FRotator::ZeroRotator instead of leaveing it Unitialized. You also dont need the "&" on your FVector and FRotator.

I dont See anything else that can cause trouble.

more ▼

answered Jun 02 '16 at 09:25 PM

avatar image

6.9k 143 24 168

(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