No MeshRenderer attached to "Unit" game object - SOLVED

Finished Unit Selected Visual, Singleton lecture and ran through Unity, console is throwing up a MissingComponentException: There is no ‘MeshRenderer’ attached to the “Unit” game object, but a script is trying to access it. I have a Mesh Renderer on the SelectedVisual object, but I can’t find where we were supposed to put one back on the Unit after removing it early in creation. Game runs, but both prefabs have green Selected Visual circle under them. If you can just point me to lecture and time stamp that I missed, I can probably go from there, thanks!

1 Like

While I can’t point to the lecture where this is changed offhand, I can tell you that the UnitSelectedVisual script should only be on the SelectedVisual GameObject, a child of the Unit, with a link to the Unit in the component. The Unit itself shouldn’t have the script on it.

What code is firing that error? The Unit itself shouldn’t have a MeshRenderer so like Brian mentioned it sounds like you accidentally added a script on the wrong object.

Ya’ll are exactly right! In my haste, I put the script on the base Unit object and not the SelectedVisual object. Solved, my thanks!!

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms