Quantcast
Channel: Questions in topic: "renderer.enabled"
Viewing all articles
Browse latest Browse all 99

No 'Renderer' attached to the "Main Camera"

$
0
0
My Error Message I get at any frame (cause its in LateUpdate): "*MissingComponentException: There is no 'Renderer' attached to the "Main Camera" game object, but a script is trying to access it. You probably need to add a Renderer to the game object "Main Camera". Or your script needs to check if the component is attached before using it.*" I call this function in LateUpdate(): CharacterFade(); void CharacterFade() { if (RPG_Animation.instance == null) return; if (distance < firstPersonThreshold) RPG_Animation.instance.renderer.enabled = false; else if (distance < characterFadeThreshold) { RPG_Animation.instance.renderer.enabled = true; float characterAlpha = 1 - (characterFadeThreshold - distance) / (characterFadeThreshold - firstPersonThreshold); if (RPG_Animation.instance.renderer.material.color.a != characterAlpha) RPG_Animation.instance.renderer.material.color = new Color(RPG_Animation.instance.renderer.material.color.r, RPG_Animation.instance.renderer.material.color.g, RPG_Animation.instance.renderer.material.color.b, characterAlpha); } else { RPG_Animation.instance.renderer.enabled = true; if (RPG_Animation.instance.renderer.material.color.a != 1) RPG_Animation.instance.renderer.material.color = new Color(RPG_Animation.instance.renderer.material.color.r, RPG_Animation.instance.renderer.material.color.g, RPG_Animation.instance.renderer.material.color.b, 1); } } What am I doing wrong and how do I fix it?

Viewing all articles
Browse latest Browse all 99

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>