How can i set the display name of a spawned object?

i have a tree that replaces itself. default name is tree1, but when it respawns, the name changes to tree2. i want to set the display name in the begin play for the actor. how do i do that?

1 Like

Do not rely on display name functions; Display names are used in Editor only and you can’t use display names for code in packaged game, it won’t work. If you are looking for objects in game by name and didn’t test in packaged shipped game yet, well… You’ve got some code to fix.

By the way, to change name you can simply edit the name on the Details panel.

thats not exactly what i was asking. and you didnt answer the question. i just want to set its name when begin play hits.

You can’t set an object’s display name by code because they are not used in gameplay code. Objects in game are identified by ID, not display names thus there’s no function to set an Actor’s display name in game code.

It would be helpful for debugging purposes to be able to modify the display name on spawn… Because the World Outliner displays dynamically spawned objects in it’s list.

So Making excuses why a function doesn’t exist is just making excuses.

1 Like

Yeah, the name system in Unreal is beyond broken and useless. Even if it’s not used internally, for game logic programming it’s handy to use names if you are consistent in naming them. But we even can’t in blueprint.

With Blutility having more and more utility to spawn objects and do stuff editor time this problem is only growing.

Since all objects use id’s anyway, it would be trivial to add and keep track of an internal map that connects the id to the name right. That would even allow for equal names if you really wanted.

Are you sure you mean “display name”? Because if you mean the name in the world outliner (top right) I think that’s known as the actor label. That can be set in a blueprint using Set Actor Label.

4 Likes

I know I’m very late to this, but wanted to correct some misinformation - I use display names in code all the time. I understand why you’d want to avoid them, but my external UI references objects by name - another BP maps the display name to the “actual” internal ID name to actually use. I’ve been doing this for years, and can promise you that you can use display names at runtime if you do it correctly - the caveat being that multiple objects can have the same display name, but that’s on the developer to make sure it doesn’t happen. It makes the UI a lot cleaner, and also means that I can update objects and not break my UI because I can just name it the same thing.

The Unreal Engine you use today is not the same back then.
At that time it was EditorOnly.