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 can I get a Blueprint Actor in C++?

Here is my scenario:

  1. [in VS]Derive a subclass called AStrikeZone from AActor, which basically contains a UBoxComponent as a trigger volume

  2. [in editor]Create several blueprint instances that derive from AStrikeZone in the editor

  3. [in editor]Adjust the blueprint zones in the editor

  4. [in edtior]Set the above zones to a player blueprint whose exposed C++ properties are declared like this:

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=blahblah) TSubclassOf BackCourt; Now in the blueprint's default panel, I can set AStrikeZone blueprints to BackCourt property. The problem is, by using TSubclassOf<>, the reference 'BackCourt' has a type of UClass instead of AActor, and all the methods and properties defined on AStrikeZone become unavailable as the compiler throws this error:

    'getBoxExtent' : is not a member of 'UClass' Then I tried to expose the property as a raw pointer:

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=blahblah) AStrikeZone* BackCourt; Now in its blueprint defaults panel, I can see the instanced blueprints showed up in BackCourt's dropdown menu, but they seems to be un-selectable(click them and nothing happened...)

Anyone pls shed some light onto this? Any help would be great!

Product Version: Not Selected
more ▼

asked Oct 27 '14 at 08:11 AM in C++ Programming

avatar image

6 3 3 5

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

2 answers: sort voted first
more ▼

answered Oct 27 '14 at 09:20 AM

avatar image

6 3 3 5

avatar image J_T_R Oct 27 '14 at 10:23 AM

Updated: the answer in the above link is not sufficient UClass::GetDefaultObjct() just creates an empty object, and ignores the objects created in editor.

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

TSubClassOf will allow you to select from a dropdown the classes that derive from the one you specify, but that is not an instance. That is usually used to set the class of an actor you are going to spawn in the world and you need to know what the uclass is. I'm not sure how to do that for instances, i tried TSubObject of an actor and it crashed.

more ▼

answered Oct 27 '14 at 02:00 PM

avatar image

6k 163 129 305

avatar image J_T_R Oct 28 '14 at 02:10 AM

I believe TSubobject<> is usually used with ActorComponents.

There are several predefined 'singleton-like' actor classes (like gamemode, gamestate, etc) whose references are kept/managed in UWorld and can be accessed using the GameplayStatistics helper methods. TSubclass is perfect for this kind of use as you can set your customized blueprint class to GameMode and then in the code get access to the instanced actor.

For runtime spawned actors, it's also not a problem, as UWorld::SpawnActor<...>(...) always returns a pointer to the spawned actor.

The only trouble is to deal with editor-time created actors. To get access to them in native code, a general solution is to iteratively search all actors/objects by name. Besides that, I think it is also reasonable to make those actors register themselves to somewhere in their first Tick()

avatar image xlar8or Oct 28 '14 at 01:47 PM

To do the dropdown of actor instances you just do:

 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = GeomProcess)
 AActor *    GeometryMesh;
(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