I have an entity with a model that contain few MeshInstances, and I’m trying to update the position of the each MeshInstance independently.
But when I try the following code
this.entity.model.model.meshInstances[i].node.setPosition(newPosition);
Where newPosition is pc.Vec3. The position of the MeshInstance is not changing, it remains the same. Is there something I’m missing?
I want to change the position and rotation of MeshInstances individually
Hi @PC_Coder,
That should work as expected, gave it a quick try on the following simple example:
https://playcanvas.com/editor/scene/440081
Can it change the position of MeshInstances individually? If it contains the submeshes? Because in my case it is changing the position of complete mesh.
https://playcanvas.com/editor/scene/1078658
Here i’m trying to change the position of windows of a truck mesh which are at index 2 by
this.entity.model.model.meshInstances[2].node.setPosition(-1,-1,-1);
but it changes the position of complete truck
Right, so for the tyres it worked:
But as you said, not for the windows, the reason is that the trunk, body and window mesh instances all share the same node.
Here I imported in Blender and you can see them grouped like that. You can split them in Blender or a similar app to separate nodes and then you will be able to move them on their own:
1 Like
Okay thanks for your quick assistance 
1 Like