Help on Unit Selected Visual - Unity Turn Based Strategy

I have checked my code over and referenced the code found in the Gitab files. I still can not figure out why I am getting the following error.

“MissingComponentException: There is no ‘MeshRenderer’ attached to the “Unit” game object, but a script is trying to access it.
You probably need to add a MeshRenderer to the game object “Unit”. Or your script needs to check if the component is attached before using it.”

In test, Unit does show the icon underneath them when clicked, however Unit(1) does not.

I get the error for both units however. Unit and Unit(1)

The error tells you all you need to know: You don’t have a mesh renderer attached to the game object. Can you show the objects in the hierarchy and their respective inspectors?


image

image

There it is. UnitSelectedVisual is trying to get a renderer from this game object, but there isn’t one. This component should only be on the SelectedVisual game object - which you have

Nevermind I got it after putting 2 and 2 together, LOL.

I wanna say thank you so much for the help, I cant believe it was right in front of the whole time.

Thanks!

All good. I realise now my answer could probably have been clearer.

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

Privacy & Terms