Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to lerp change emission material color?

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));




Best Answers

  • MouledouxMouledoux Member
    Accepted Answer

    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.

  • MouledouxMouledoux Member
    edited July 2020 Accepted Answer

    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.


  • @Mouledoux Thanks for the quick reply! It works but the intensity is too high... how do i reduce it?

  • tomfortomfor Member
    edited August 2020

    I am looking for an answer to the question: is it possible to change the color of the main menu and change the font on your own in the admin panel of the site, which is created on WordPress?

Sign In or Register to comment.