Im getting an error for this code
using UnityEngine;
using System.Collections;
public class ExampleBehaviourScript : MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown(KeyCode.R))
{
GetComponent<SpriteRenderer>().color = Color.red;
}
if (Input.GetKeyDown(KeyCode.G))
{
GetComponent<SpriteRenderer>().color = Color.green;
}
if (Input.GetKeyDown(KeyCode.B))
{
GetComponent<SpriteRenderer>().color = Color.blue;
}
}
}
I just started using unity 2 days ago, I have absolutely no coding knowledge so you will need to explain this like its to a 10 year old… I just put this together using google searches and copy pasting what others wrote. I’m trying to make it so a circle will change colour based on a key press, eg: if r is pressed, the circle goes red. Not sure if this does anything like that but yeah…
Also, what does ‘public class’ mean? What are the two top lines, “using UnityEngine; and using System.Collections;” mean? They seem to be in most code I see. What does void mean in this context?