Hello Ladies and Gentlemen,
I decided to learn scripting in Unity. I started from this tutorial:
I wanted to play with this, but… now, it’s unity 5, few api changes. Script is:
if(Input.GetKeyDown(KeyCode.R))
{
gameObject.renderer.material.color = Color.red;
}
compiler shouts: You need to use GetComponent instead. My question is , how to do this ?
I tried:
gameObject.GetComponent<Renderer>().material.color = Color.black;
fyi: when you post code into the forum you should use [ code] [/ code] tags, it really helps with the readability, there is a sticky on them at the top of the scripting forum.