[SOLVED] Disabling Mesh Instance Nodes

Hello (again!),

I have run into an issue with enabling/disabling individual mesh instance nodes. I am importing an FBX animation, and as far as I can tell, the animation does not impact whether these nodes are enabled or not.

You can see from the basic code below that I am trying to disable 2 out of 3 instances. The console says this operation “worked,” but if I check the status later, they are all enabled. Additionally, I can see they are enabled. Is there something I am missing with how to enable/disable mesh instance nodes?

    var rndIndex = Math.floor(Math.random() * this.meshInstances.length); 
    
    var i;
    for(i = 0; i < this.meshInstances.length; i++)
    {
        this.meshInstances[i].node.enabled = (rndIndex == i);
        console.log(this.meshInstances[i].node);
    }

Any help is appreciated!

Hi @Travis,

I am not sure if enabling/disabling the graphNode directly works or not, but if you are just searching for a way to disable rendering for those mesh instances you can simple use the visible property.

Directly on the mesh instance:

// this will disable rendering of this mesh instance
meshInstance[i].visible = false;

https://developer.playcanvas.com/en/api/pc.MeshInstance.html#visible

1 Like

That did the trick! I didn’t catch the visible property in the list and assumed I had to apply this to the node.

Thanks!

1 Like