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"

How do I spawn Blueprints?

I would like to know how to make this work.

  ConstructorHelpers::FObjectFinder<UClass> BlueprintObject(L"Blueprint'/Game/Blueprints/Blueprint_Effect_Explosion.Blueprint_Effect_Explosion'");            
     FActorSpawnParameters SpawnParams;
     SpawnParams.Instigator = Cast<APawn>(Owner);
     SpawnParams.bNoFail = true;
     GWorld->SpawnActor<UBlueprint>(BlueprintObject.Object, GetActorLocation(), FRotator(0, 0, 0), SpawnParams);

 UObjectGlobals.cpp(2204): Fatal error:
 FObjectFinders can't be used outside of constructors to find Blueprint'/Game/Blueprints/Blueprint_Effect_Explosion.Blueprint_Effect_Explosion'
 UE4Editor.exe has triggered a breakpoint.

I would like to know how to make this work. The reference to the blueprint is correct. I have checked.

Product Version: Not Selected
more ▼

asked May 23 '14 at 10:10 PM in C++ Programming

avatar image

116 18 24 24

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Spawning Blueprints

I gave the world my SpawnBP template function to make doing this easy

Wiki Tutorial



more ▼

answered May 24 '14 at 03:28 AM

avatar image

10.6k 446 346 1088

avatar image Skydive May 24 '14 at 04:20 PM

Ugh, please may I have an example of how to load the blueprints UClass* and call the function using that. Sorry. :/

avatar image Kochab May 26 '14 at 11:06 PM

Hi, Rama. I'm wondering how you get the actor blueprint. Are you doing it like this?:

  ConstructorHelpers::FObjectFinder<UBlueprint> BlueprintObj(TEXT("Blueprint'/Game/Blueprints/BP.BP'"));
  BPptr = NULL; /*UBlueprint* BPptr;*/
  if (BlueprintObj.Succeeded())
       BPptr = BlueprintObj.Object;

And then you'd pass in BPptr to this?:

  AActorBaseClass* NewActor = UFunctionLibrary::SpawnBP<AActorBaseClass>(GetWorld(), TheActorBluePrint, SpawnLoc, SpawnRot);
avatar image Skydive May 28 '14 at 08:59 AM

does it work?

avatar image DoctorPC Aug 26 '14 at 04:00 PM

What was left unclear to me is, where exactly do I put the function in? It syas I should put it in the .h file of the tepmlate, but in what kind of .h file do I put it in (actor, pawn, etc.) Thanks!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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