Hi all,
I wondering how layers work, atm, my custom layer, doesn’t render in the game.
Could I have a basic breakdown on how to get layers to work please?
Kind regards to all,
Adam Burgess
Hi all,
I wondering how layers work, atm, my custom layer, doesn’t render in the game.
Could I have a basic breakdown on how to get layers to work please?
Kind regards to all,
Adam Burgess
Hi @adamburgess38,
Layers are indeed used to create sets of models that can be rendered in a specified order.
You need to assign the layer you’ve added to your active camera, if you expected it to do any actual rendering.
You assign it in a similar way you do with the models, just with a slight difference, you need to set the anew array each you change the .layers
property (to trigger the property setter):
const modelLayers = entity.render.layers;
modelLayers.push(newLayer.id);
entity.render.layers = modelLayers;
const cameraLayers = cameraEntity.camera.layers;
cameraLayers.push(newLayer.id);
cameraEntity.camera.layers = cameraLayers;
// same way with lights if required etc.
So this has to be done from the script? And cannot be done from the layer?
All this can be set up inside the Editor without a script. Have a look here at the manual please: Layers | Learn PlayCanvas
I’ve looked into this, but the world still does not seem to pick up my new layer
The layer has been added to my camera entity, my light entity and the sub layers order but still does not work.
Editing it now, and it works on this. Very Strange indeed
You are still setting the layers like this:
You definitely need to change that to set a reference to the array, check my reply above.
Thank you, the issue was I set the layer Transparent, rather than Opqaue