this is my first question so if I’m not in the correct format or rules please let me know and I’ll change it okay I’m making an invisibility script which changes multiple objects and after i change them i want them to revert back after the invisibility runs out.
changing the materials works perfect but in Update()
they are not changing back there are 8 objects the first with 8 materials and the rest around 3 materials and most are different so i was hoping there is code to make it reset like when you exit the game play and go back to editor mode
this is main line i want to change
InvisablityGameObjects*.GetComponent<Renderer>().materials = Materials;*
below this is all the code i think you would need and thank for anyone helping
public class TriggerPickUp : MonoBehaviour {
public GameObject GunSwaper = null;
public Text Display = null;
public int Weapon;
public int Picking;
public Health healthbar;
public AudioSource OverShield = null;
public GameObject UIMaster = null;
public GameObject[] InvisablityGameObjects;
public bool Invisible;
public Material[] Materials;
public int Counter = 0;
public Material[] mat_MainInvisible;
public float visabilityTimer = 5;
private void Update()
{
if(Invisible)
{
if (visabilityTimer < 5)
{
visabilityTimer += Time.deltaTime;
}
else
{
for (int i = 0; i < InvisablityGameObjects.Length; i++)
{
for (int j = 0, n = InvisablityGameObjects*.GetComponent().materials.Length; j < n; j++)*
{
InvisablityGameObjects*.GetComponent().materials = Materials;*
}
}
Invisible = false;
}
}
}
private void OnTriggerEnter(Collider other)
{
if (other.GetComponent())
{
for (int i = 0; i < InvisablityGameObjects.Length; i++)
{
for (int j = 0, n = InvisablityGameObjects*.GetComponent().materials.Length; j < n; j++)*
{
Materials = InvisablityGameObjects*.GetComponent().materials;*
InvisablityGameObjects*.GetComponent().materials = mat_MainInvisible;
_}
}
Invisible = true;
visabilityTimer = 0;
}*_