Is their a way to change the color of a material in a script ?
the players have markings around their arms and helmets and I'd like to be able to change the color of the markings according to their team. Is there a way to store the material in the player information and access it to change the color?
here's the class where I store the player's parameters
public class PlayerInfo
{
public GameObject Player { get; set; }
public int Health { get; set; }
public int Kills { get; set; }
public string PreviousTeamState { get; set; }
public string Coordinates { get; set; }
public string PreviousLivingState { get; set; }
public Animator PlayerAnimator { get; set; }
}
where I create my new players :
if(!Players.ContainsKey(newID))
{
var playerInfo = new PlayerInfo { Health = 100, Kills = 0, Coordinates = "0", PreviousLivingState = "1", PreviousTeamState = "1"};
Players[newID] = playerInfo;
player = Instantiate(PlayerPrefab, new Vector3(10, 10, 10), Quaternion.identity);
player.name = newID;
Players[newID].Player = player;
Players[newID].PlayerAnimator = player.transform.GetChild(0).GetComponent<Animator>();
Players[newID].PlayerAnimator.enabled = true;
}