Hey! Can anyone fix my issue? My emission value doesn’t change, but all the tutorials I’ve watched tell you to write “material.Disable(”_EMISSION");" and yes I have a variable for the material. I want my material emission to flicker when I am reloading. Any answers?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EmisionControl : MonoBehaviour
{
public Material emitValue;
public GunScript gunScript;
// Start is called before the first frame update
void Start()
{
emitValue.EnableKeyword("_EMISSION");
}
// Update is called once per frame
void Update()
{
if (gunScript.isReloading)
{
StartCoroutine(Flicker());
}
}
IEnumerator Flicker()
{
emitValue.DisableKeyword("_EMISSION");
yield return new WaitForSeconds(1f);
emitValue.EnableKeyword("_EMISSION");
yield return new WaitForSeconds(.6f);
emitValue.DisableKeyword("_EMISSION");
yield return new WaitForSeconds(.4f);
emitValue.EnableKeyword("_EMISSION");
yield return new WaitForSeconds(.4f);
emitValue.DisableKeyword("_EMISSION");
yield return new WaitForSeconds(.6f);
emitValue.EnableKeyword("_EMISSION");
}
}