- Home /
[Solution in answers] Skinned Mesh Renderer only appears if it's visible in the Scene window
So, I've got an animated knife as a child of the first person camera. When I click, the knife swings. Everything works great! Except when the scene view isn't pointed at my player...
If I play the game in a maximized game window, the knife doesn't render. If I don't play maximized, but don't have the scene window on screen, the knife doesn't render. If I walk out of view of the scene window, the knife doesn't render.
It's acting as if the scene view is my "camera," and when the skinned mesh renderer isn't displayed by that "camera" it doesn't render. You'd expect this behavior but with the actual camera instead of the scene view.
I've never run into a problem like this before, so I'm very very confused. I'm sure there's a setting or something that I'm overlooking. Any help is greatly appreciated :)
Answer by hawksandwichgames · May 29, 2018 at 06:55 AM
Alright everyone, I've found a solution. I don't know exactly what fixed it, but I've changed a bunch of settings on the knife and camera. For anyone with a similar problem, here are the settings I suspect have something to do with it.
The Animator component has Culling Mode set to Always Animate.
The Skinned Mesh Renderer has Update When Offscreen checked true.
The Skinned Mesh Renderer has Dynamic Occluded set to false.
The Camera has Occlusion Culling set to true.
The Camera has Allow Dynamic Resolution set to false.
I'll mark this answer as correct and leave the question here so it might help someone else.
All points are valid regarding Skinned $$anonymous$$esh Renderer.
The Animator component has Culling $$anonymous$$ode set to Always Animate.
The Skinned $$anonymous$$esh Renderer has Update When Offscreen checked true.
The Skinned $$anonymous$$esh Renderer has Dynamic Occluded set to false.
The Camera has Occlusion Culling set to true.
The Camera has Allow Dynamic Resolution set to false.
Answer by miron83 · May 10, 2021 at 07:44 AM
@hawksandwichgames Actually only the The Skinned Mesh Renderer -> Update When Offscreen -> checked true does the trick. However, this isn't the ideal sollution because it lowers the performance as the mesh bounds are remapped all the time. It's ok if that happens for a single mesh but when you have them hundrets it can really impact the framerate.
Check: https://docs.unity3d.com/Manual/class-SkinnedMeshRenderer.html and https://docs.unity3d.com/Manual/class-SkinnedMeshRenderer.html#bounds
the mesh is remapped when Update When Offscreen is set to true, when you set it back to false the bounds get to the original possition.
in previous versions of Unity you could recalculate the bounds with this bit of code.
modelObject.GetComponent<SkinnedMeshRenderer>().sharedMesh.RecalculateBounds();
And that would be great so that I could rempap the bounds when the animation happnes. However, it doesnt work anymore, or at least not for me...
Answer by x1alphaz1 · Nov 06, 2021 at 01:46 PM
For Anyone who's facing this issue. U need to set the rootbone position of the attached object to the position of the Main SkinnedMeshrenderer rootbone position
Example:
O1 = Main.GetComponent<SkinnedMeshRenderer>();
O2 = Attached.GetComponent<SkinnedMeshRenderer>();
O2.rootBone.transform.position = O1.rootBone.transform.position;