I’ve got another project that uses a single camera to do this using layers and clearing the depth buffer before I render the gun layer.
https://playcanvas.com/project/1067030/overview/fps-pit-fork
See layer order:
And code that adds the clear depth buffer flag on the Clear Depth layer https://playcanvas.com/editor/code/1067030?tabs=131104600&focused=131104600
(function() {
const app = pc.Application.getApplication();
app.on('start', () => {
// We have special layer that we want to set so that it clears the depth buffer
// This helps us render the weapon on top of the world
const clearDepthLayer = app.scene.layers.getLayerByName('Clear Depth');
clearDepthLayer.clearDepthBuffer = true;
});
})();