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"

How to spawn Actor from string path to Actor Blueprint ?

I got my self to this point:

             FStringAssetReference itemRef = "Class'/Game/Blueprints/Items/Chest/chestBlue.chestBlue_C'";

             UObject* itemObj = itemRef.ResolveObject();

             AARArmor* item = GetWorld()->SpawnActor<AARArmor>(itemObj->GetClass(), SpawnInfo);

And the first two lines work. When inspecting in debugger itemObj, UClass is pointing the the right blueprint.

But SpawnActor is returning null. What I'm doing wrong ?

Product Version: Not Selected
Tags:
more ▼

asked Jun 22 '14 at 11:31 AM in C++ Programming

avatar image

iniside
1.6k 105 97 185

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

2 answers: sort voted first

I figured it out:

             FStringAssetReference itemRef = "Blueprint'/Game/Blueprints/Items/Chest/chestBlue.chestBlue'";

             UObject* itemObj = itemRef.ResolveObject();
             
             UBlueprint* gen = Cast<UBlueprint>(itemObj);

             AARArmor* item = GetWorld()->SpawnActor<AARArmor>(gen->GeneratedClass, SpawnInfo);

All that is needed, is to create UBlueprint (figures...) and then just get GeneratedClass. You can shorten it by directly casting to UBlueprint.

more ▼

answered Jun 22 '14 at 11:49 AM

avatar image

iniside
1.6k 105 97 185

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

I found that the ResolveObject always returns NULL because the blueprint is not yet loaded.
So I added the following before the Resolve....

[CODE]

TArray LoadedObjects;

if (EngineUtils::FindOrLoadAssetsByPath( selAssets[i].PackagePath.ToString(), LoadedObjects, EngineUtils::ATL_Class)) { // Do the resolve here... }

[/CODE]

more ▼

answered Feb 09 '15 at 03:59 AM

avatar image

SND R Keene
968 31 120 113

(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