Edit: found the solution! Add a generic entity to the scene hierarchy, add children to it, and it becomes a folder (I would guess the ‘folder’ part is just the icon used?). I’d still be interested in any comments on approaching template/instance entities in general though.
I’m attempting to create a set of ‘template’ entities, which will be cloned at runtime. At the moment, the template entities are at root level in the scene hierarchy. The trouble is, the cloned instances—which are actual gameplay objects—are also added to the root level, so that it becomes impossible to distinguish between the two (when using findByName(…) to query the hierarchy). I noticed a solution this in the procedural levels tutorial (PlayCanvas 3D HTML5 Game Engine), where they place template entities into a ‘Templates’ folder in the scene hierarchy. However, I have been unable to find a way of creating folders there!
Also, more generally, if there is another, better way of solving the template vs. instance distinction issue I’m dealing with here, I’d gladly hear about alternate solutions
Well since i don’t know what kind of project u are developing is difficult to tell something specific, you can use tags or if you use mouse when you click on entity you can ‘catch’ that specific one as target of the raycast, or change the name of each cloned entity, with some more information about your project or a link it will be more easy
What is the problem with simply having one entity called “templates” which will be disabled, and other entities inside - which are templates. And cloning them to make instances?
The specific problem I was having is now solved, I was just confused about the folder icons I saw in the tutorial I linked to originally. I now realize if I make a ‘templates’ entity (as max suggests), and it has no other properties other than being a parent to other entities, then it gets a folder icon. That’s my understanding anyway. I was trying to find a specific way of adding a folder to the scene hierarchy, without realizing a folder is just another entity
If you’re curious, the project is here: https://playcanvas.com/project/479850/overview/rocks —I was cloning bullets and asteroids from template entities.
My more general question wasn’t related to that particular project though, I was just wondering about general best practices for doing this kind of thing. It seems like the template ‘folder’ approach is fine though.
The way I handle templates is to do the same as you have done here, the template entities being attached to a parent entity.
However, instead of using findByName to find the template entity in a script, I use an entity reference in the script attribute.
Icon by the entity, is just Editor trying to be helpful to identify different purposes of entities. In engine they all are just entities. There is no such thing as “folder entity”.