I’m using a simple script to pulse the emission parts of my material. It works nicely as I want it to, but whenever it’s active it’s causing my game to stutter when my player moves around.
This is the code I am using:
public class emissionPulse : MonoBehaviour {
public float frequency = 1f;
public Material material;
public Color emissionColor;
// Use this for initialization
void Start()
{
emissionColor = material.GetColor("_EmissionColor");
}
// Update is called once per frame
void Update()
{
float glow = (2 + Mathf.Cos(Time.time * frequency));
material.SetColor("_EmissionColor", emissionColor * glow);
}
}
Anyone know why this is happening or another way to achieve this effect?
Thanks.