void OnTriggerEnter2D(Collider2D collision)
{
if (gameObject.tag == "Player")
{
if (collision.gameObject.tag == "SpawnPointTeam1")
{
gameObject.tag = "PlayerTeam1";
gameObject.GetComponent<SpriteRenderer>().color = Color.red;
}
else if (collision.gameObject.tag == "SpawnPointTeam2")
{
gameObject.tag = "PlayerTeam2";
gameObject.GetComponent<SpriteRenderer>().color = Color.green;
}
}
The basic idea of this code, is that wherever the player is spawned will have a trigger which decides the team.
I have no idea how to sync this bit of code to late players who weren’t there when the color was changed from the default white.
The tag also doesn’t sync.
Can anyone help?