Keep object from going through the floor

Ok so i am bored and made this little thing (game) but i cant seem to keep the gun from going through the floor when you look down:

I just cant seem to prevent the weapon from going through the walls and floors :frowning:

Normally, the way to do this is to render the gun last (on a separate layer) and have the gun materials not test or write to the Z buffer. That way, it will render on top of everything that has already been rendered to the buffer.

1 Like

how do i do that? im not quite understanding that part…

you might wanna try a collision depending on the rigidbody check if it’s static or dynamic that probably could help

i have tried that still didnt work

hmm probably has something to do an collision on a certain or object or with where the gun is located in the root

Sorry to revive this dinosaur topic. This is the only similar topic that I found unfortunately.

Having trouble figuring this out also. Is there any documentation for this by any chance? I examined the API Reference for Layer but kind of ran into a wall of how to implement this.

What I did was add a new layer for the gun and added the sub layer at the end of the render order list. Then what I did was remove the world layer from the gun model and only add the new layer onto it following some unity examples. Since the unity examples add a secondary camera and make changes to depth and culling I got stuck trying to apply this on Playcanvas. Would there be a guide on how to achieve this?

Currently there is no guide for this but it’s possible via the same method of using two cameras


The important part is to ensure the weapons camera is clearing the depth buffer (so it can render on top) but not clearing the color buffer.



Noob question: I tried it myself but the light does not render on the gun model. How can I fix this?

Oops. Forgot that this project has IBL from the cubemap.

Add the weapons layer to the light