- Home /
"MissingComponentException: There is no 'SkinnedMeshRenderer' attached to the "Player" game object"
A script I was still editing was working properly until I attempted to add a few lines which ended up breaking this entire script. After undoing the recent additions and pretty much reverting the script back to its former state, it's giving me an error for something that has never been a problem before.
Below is the part which is properly referenced which also has the Skinned Mesh Renderer attached. It is a child of the Player game object
public SkinnedMeshRenderer tpsHead;
void Start()
{
tpsHead = GetComponent<SkinnedMeshRenderer>();
}
//FPSmode will be called from a different script
public void FPSmode()
{
tpsHead.enabled = false;
}
I have other parts which are also being affected by this sudden error, and they all have skinned mesh renderers properly attached. The parts have been referenced properly and I've used GetComponent for all of them. I tried changing my script back to before the errors started happening but with no luck. I'm not entirely sure what's going on suddenly. Maybe it somehow started trying to get the component of the parent Player gameobject instead?
@agreen63 You say the Skinned $$anonymous$$esh Renderer is a child of the Player, yet you say you are using GetComponent and not GetComponentInChildren (only the latter would find within the Player children). Also, maybe you can post your code line of where you get the component that throws the error? And double check your script is not accidentally added to a different object as well; one way to highlight it is to use EditorGUIUtility.PingObject.
Added a sample of my script of how I'm trying to disable the renderer. I pretty much used https://docs.unity3d.com/ScriptReference/Renderer-enabled.html to write these lines in order to enable or disable my skinned mesh renderers, except I used methods ins$$anonymous$$d of Update
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Renderer on object disabled after level reload 1 Answer
change the wrap mode of a 2d animation 0 Answers
Null component is not null? 1 Answer