I was playing VR Chat today and I realized that the head is actually not being rendered which fixes the clipping issue when you can see inside of a character’s head in first person. How is that even possible?
Sometimes the head mesh is apart of the rest of the body so you can’t just disable the renderer… How?
There is no go-to solution for this. Most FPS games do not render the character at all in first person view. They usually have a seperate first person view model that only represents the arm holding the gun / tool / whatever and nothing else. You barely see FPS games where you can see your body when looking down. Of course there are exceptions and they either have a specific “camera mount” so it’s offset from the head and moves with the head like your eye’s in the real world do not pivot in place but move with your head, or in most cases they have a seperate first person model.
See this part where the Portal developers talk about when to render third person and when to render the first person model.
Developing games is often times more than throwing premade things together, especially when you have special needs / requirements. Premade stuff only gets you that far. Of course another solution would be to implement a special clipping shader (like it was mentioned on your duplicate question) that doesn’t render anything above a certain y position. Though this could cause other problems if some animations move the hands above the head, they would be clipped as well.
The game can not decide for you what you would consider “the head”. Meshes / characters are constructed out of triangles. They don’t have to be in a particular order and if it’s a single mesh, it’s hard to impossible to tell what may be considered part of the head and what not. As it was mentioned, using clipplanes is one generic approach which probably introduces more issues than it solves.
Just as an examples, here they used both at the same time. They used a clipped version of the third person model just to render the feet / legs and a seperate first person model that only shows the hands / weapon. If you want to become a developer you should just look around what others have done. Don’t expect others doing the research for you and present you a step by step guide what you should do. Being a developer means you’re a problem solver, that’s your main task.
It the head is a different Gameobject form the boddy, it will have its own mesh render component, so disableing that component will make to not render the head (all other components can be running)
I also had a VR character attached, and I had the same problem – the character’s head and body were a single mesh, so it was hard to hide. I didn’t change the head offset because then the character becomes skewed when looking sideways and trying to look at yourself.
What helped me was that my view camera was linked to the CenterEyeAnchor, so I attached extra code to make the camera appear slightly further than the head’s position.
Here’s the code:
using UnityEngine;
public class PushCameraForward : MonoBehaviour
{
public float forwardOffset = 0.1f;
void Update()
{
transform.position += transform.forward * forwardOffset;
}
}
Choose the distance provided, mine was (-0.2), and everything works fine – the view is good, the character’s position doesn’t change, and the head is not visible.