Name of runtime spawned entities not inherited from template


This is a bit of a nitty case, but the other day I was trying to access the name of an entity that I had spawned from a template at runtime, and found that it was always called “RootNode” no matter what I called the template.

If I spawned the entity manually before running the project (by drag dropping the template into the scene), the name of the entity was the same as that of the template, which is what I would expect.

Soo… there seems to be “bug” that runtime spawned entities does not inherit the name of their template. Anyone else bumped into this issue?

Hi @Astra,

I think that’s not the case in my code. I can see that calling instantiate() on a template results in an entity that is named after the template.

Are you able to share some code or project that reproduces your issue?

May be related to Be able to change the name of the root entity in a template asset · Issue #713 · playcanvas/editor · GitHub


Yess, that’s it!

hm… I also used instantiate() but perhaps you named your entity before you converted it to a template? At least the GitHub issue is exactly the same as I experienced.

Here’s a snippet of the code that spawned our template:

let newEntity = newEntityAsset.resource.instantiate();