When the first person arms and items are drawn to the screen they are drawn using a second camera (called camera stacking). This prevents the objects from clipping with walls that are in front of the character. This works well for the standard pipeline, but the universal render pipeline offers a better and more efficient solution.
The camera’s Renderer can be changed which allows you to specify the order that the objects are rendered. The Ultimate Character Controller uses this method to ensure the first person arms and items do not clip with other objects. The following steps need to be performed in order to use this method:
- Setup your project to use the universal render pipeline.
- Import the universal render pipeline integration package (links below).
- Add the OverlayForwardRendererData reference to universal render pipeline’s setting file.
- Change the camera’s Renderer to the OverlayForwardRendererData that was specified in the last step:
- On the Camera Controller select the First Person View Type and change the Overlay Render Type to Render Pipeline:
- To prevent duplicate shadows ensure Cast Shadows is set to Off for all of the Renderers on the first person objects. For example, with the example character you’ll want to ensure Cast Shadows is set to Off for all of the objects underneath the Nolan/First Person Objects GameObject.
- On your character’s Perspective Monitor the Invisible Material should be set to the InvisibleShadowCastorUniversalRP material included in the download.
- If you are using the Object Fader component set the Color Property Name to “_BaseColor”.