Problem with rendering component

Hi guys,

I wrote a shooting script, but i wanna improve it making the bullets remove the rendering component of the object they hit, without destroying it, just removing the Redering component when hit something.

Thank you all very much.

Assuming you are using Raycast…

Let’s say the variable to store the object you’ve hit with the raycast is named hit.

Then you would do something like:

hit.gameObject.GetComponent("MeshRenderer").renderer.enabled = false;