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"

SetActorLabel before gameplay

I'm trying to set the actor label (the label in the scene hierarchy) in my OnConstruction() method, but doing so just crashes the engine. I can do it just fine in PostInitializeComponents(), but that renames it only when the game is being played. Here is the code for that:

 void AWorldItem::PostInitializeComponents()
 {
     Super::PostInitializeComponents();
 
     SetActorLabel("TestLabel");
 }

How do I rename my actor from the default actor name, through C++, before the game starts?

Product Version: UE 4.12
Tags:
more ▼

asked Jul 11 '16 at 08:11 PM in C++ Programming

avatar image

Dooskington
6 2 5

avatar image Digi Labs Dan Jul 11 '16 at 08:21 PM

Note that the label is for use only in Editor tools, not for shipping games (since ActorLabel is conditionally compiled based on #if WITH_EDITORONLY_DATA).

What are you trying to accomplish with the label? Maybe there is a better solution.

avatar image Dooskington Jul 11 '16 at 08:24 PM

Mostly just for organizational purposes in the scene... I plan on having a bunch of these AWorldItem actors around, and it would be nice to look in the scene and see "Potion", "Sword", "Shield", etc.

I guess I could just use the names of the blueprint class that I place in the world. I'm just confused, why is this function in the engine if it just crashes?

avatar image Digi Labs Dan Jul 11 '16 at 09:29 PM

Hmmm... I've never tried calling it from OnConstruction, but I could see how SetActorLabel could wreak havoc when renaming an actor. Maybe use PostActorCreated instead of OnConstruction. If this doesn't work, please post the stack trace of the crash.

avatar image ImVawx ♦♦ STAFF Jul 11 '16 at 08:31 PM

You can always select the Actor in the World Outliner and rename it via the Details panel.

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

1 answer: sort voted first

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will follow up.

more ▼

answered Aug 19 '16 at 02:17 PM

avatar image

ImVawx ♦♦ STAFF
6.8k 114 18 127

(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