Wrong name when spawning instances

Hi again,
so I ran into another problem with my characters. I want to spawn random templates of characters so that when there are more people in the same ‘room’ of the server, they don’t have the same characer.
This works until I have to assig the animations to the blendtree by script.
I need to call them by the CharacterName + animation name to stay flexible with all the characters.
But that only works with one Character (Ch07) and not the other one(s) since all of the others names are ‘RootNode’ when logging this.entity.name.
I tried reimporting and stuff, but that didn’t fix it.
Do you have any suggestions what else I can try?

https://playcanvas.com/project/852315/overview/charactersblendtree

Thanks:)

I’m not quite sure I understand the problem. If these are being instanced at runtime, you can change the name of the entity to be what you need?

Hi @yaustar,
what I need is the name of the instanced Template which should be the same as in the editor, so that I can assign the correct animations to the blend tree.
The animations are named like Ch07_Walking, so in code i search for the name of the character (Ch07) with entity.name, and add a ‘_walking’ to that.
This works for the one character but not for the ch12 since its ‘name’ in the console is somehow RootNode.
Strange thing is that when I manually drag this character into the scene, the attached script logs (in the instanciate) the correct entity.name (ch12) and not RootNode.
So what I was wondering, where does this entityName ‘Rootnode’ come from? nothing in my character template is named like that.
What I also noticed is that the children of the character that logs ‘Rootnode’ are named correctly like they are in editor.

I couldn’t repro the issue in the project, I just got errors when launching.

I’m not exactly sure what the setup is in the project or which entity is being used when entity.name is used.

Can you setup the project (or a fork) so that the issue can be reproduced easily please ? (also where in the code to be looking)

Wait, I see it now. You are spawning Ch12 at runtime in spawn avatar.js

Ah yes sorry, I forgot to mention that you should open 2 Tabs since you can only see the ‘other persons’ in that room but not yourself.
In the blendtree script in the Initialize, I log the name of the entity. And I think the error with the loadStateGraph logs because it doesnt find all the animations?

I’ve forked the project and hacked a few scripts to check things over: https://playcanvas.com/editor/scene/1275921

It looks like when Ch12 template was created, it was when the top most node was named RootNode. The way that the engine instances the template is different to the editor where in the Editor, the asset name is used.

This doesn’t seem to be the case with the engine method. (Not sure if bug or as designed @mvaligursky ?)

To fix this, I created a new template from an instance of Ch12 so that it is created with the top most node being the correct name of Ch12.

As another note, anim state names cannot have a . in them. That causes bugs which I thought we fixed. I will create tickets for this issue

1 Like

Ah okay I understand, thank you so much:D

I seems the root node of the GLB is called “RootNode” - so that is the name that is left on the entity when the glb is instantiated … we don’t rename it at all.

I just realised I’m talking about a template, not GLB so I should be pinging @zpaul . Sorry Martin :sweat_smile:

1 Like