It looks like you're new here. If you want to get involved, click one of these buttons!
So for my game, I want to lerp the emission color and I have the below script. It doesn't work. Any help is greatly appreciated.
My script:
using UnityEngine;
using System.Collections;
public class ChangeMaterial : MonoBehaviour
{
public GameObject player;
public Color newColor;
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
player.GetComponent<Renderer>().material.SetColor("_EmissionColor", Color.Lerp(player.GetComponent<Renderer>().material.color, newColor, 5 * Time.deltaTime));
}
}
}
This is in OnTriggerEnter. meaning it will only happen for the 1 frame when the trigger is.... triggered.
Change it to OnTriggerStay so it will run continuously, or have it start a coroutine with the lerp in it.
Intensity as in it changes too fast? or the new color is too bright?
If it's changing too fast, just replace the '5' you multiple Time.deltaTime by with a smaller one, or a variable you can change.
If the color is too bright, just give it a darker color.
Answers
@Mouledoux Thanks for the quick reply! It works but the intensity is too high... how do i reduce it?