Various tutorials and the unity documentation shows that using renderer.material creates an instance of that material, but my gameobject isn’t doing this and is editing the shared material instead that various game objects are using. In case it helps, these game objects sharing the material are all an instantiated prefab. Help is appreciated.
** public float dissolveDuration = 2;
public float dissolveStrength;
private void Update()
{
if(EnemyRPSmanager.dissolve == true)
{
StartCoroutine(Dissolver());
}
}
public IEnumerator Dissolver()
{
float elapsedTime = 0;
Material dissolveMaterial = GetComponent<Renderer>().material;
while(elapsedTime < dissolveDuration)
{
elapsedTime += Time.deltaTime;
dissolveStrength = Mathf.Lerp(0, 1, elapsedTime / dissolveDuration);
dissolveMaterial.SetFloat("_DissolveStrength", dissolveStrength);
yield return null;
}
}**