[SOLVED] Gun Clip Tutorial not working for me

I was using the tutorial project by @yaustar called “Gun clip on top” and it doesn’t seem to work. Please help me.

My Project Link: https://playcanvas.com/project/1275754/overview/fps-game

@yaustar 's Tutorial Project Link: https://playcanvas.com/project/820368/overview/gun-clip-on-top

1 Like

It will be fixed if you fix the following:

  • Set the priority of your shotgun camera to 1
  • Remove the “Clear Color Buffer” check from Shotgun camera
  • Set layers properly in Settings → Layers → Render Order

You can check it is working in this project: PlayCanvas 3D HTML5 Game Engine

1 Like

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;
    });
})();
2 Likes

That project fails to load for me

1 Like

Fork the project and go into its settings. Click on Physics and import the ammo.js.

For more information, see this page: Updating ammo.js | PlayCanvas Docs

1 Like

im sayin he should update the ammo in his project so people can see it in action

1 Like