I am 15 year old Indian student and I am creating my first 2D game in Unity. I have set the color of my player as Random and I have to set the color of my game object as of my player. But the color of the player changes Randomly. So I can't set a specific color to my game object. What I have tried:
public class SetColor : MonoBehaviour {
public GameObject player;
public SpriteRenderer sr;
void Start() {
sr = GetComponent<SpriteRenderer>();
sr.color = Color.player;
}
}
But this not worked. Please reply how to code it correctly?
player
does already reference the player? \$\endgroup\$