Can't see dynamically created entities

In this project, I have imported model that has five distinct meshes in it. In my script “testColliders”, I’m trying to iterate over the nodes of that entity and recreate all but one of them, so that I can add separate mesh colliders to those for entity picking. Then I disable the original entity so that I can see my new entities. But that is the problem, I can’t see them. I can look at the graphNodes on app.root and see that these entities are there, they have models assigned to them, they have collision components, they are positioned the same as their source nodes, they are enabled, etc, but I can’t see them at all! Nor do they respond to the mouse.

To simplify matters, the source object is at the center of the world and all the rotations are zero.

Hi @Michael_McCrickard! I am currently unable to look at your project, but are you also adding the new entities to the hierarchy?

Yes, this is what I’m doing:; Is this the right way?

I see you have a ‘GlobeRoot’ entity and a ‘globe’ entity in your scene. In your script you define var globeRoot ="globe");. So at the end of the function you disable the ‘globe’ entity and not the ‘GlobeRoot’ entity. Is that correct?

When I execute this line above, I think I am getting a reference to the node with that name? So, when I disable globeRoot, I am disabling the “globe” entity, I think. I am very new to this, so I could be missing something.

Yes that’s correct, but because you reference the variable globeRoot to your ‘globe’ entity and not the ‘GlobeRoot’ entity, I thought it could be a mistake.

If you already check the positions etc. with the console, I don’t know what could be wrong. I hope someone else can help you out.

Hello @Michael_McCrickard, I forked your project and I found out that the problem probably has to do with the way you add a model to the new entity.

Try to change this:

         _ent.addComponent("model", {
             asset: 43282335

To for example this.:

         _ent.addComponent("model", {
             type: "box",
             asset: 43282335

Also I can’t find asset 43282335 in your project, so I don’t know what you are trying to do with that.

1 Like

Thanks, Albertos! Good catch. Yeah, I should have forked the project before sending out the link. I’m still grappling with it. I have just discovered that the localPositions in the child nodes have pretty crazy values – something to do with the FBX import.

No, you did it right. If you fork a project of yourself you just make a copy of it. It makes no different for the user who receiving your link. If I (or another user) click on the link I see your editor page, but I can’t make any changes until you add me to to project or I fork (copy) the project.

I think in this case you don’t have to use the local position because you add the new entities to the root. Just try to use .setPosition() and .getPosition().