How to Change Color Over Time / Color Lerp with Unity: A step-by-step tutorial

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 10

  • @jonbednez
    @jonbednez  Год назад +2

    Do you use color lerp in your game / app? Ping pong effects?

  • @ShacharOz
    @ShacharOz 7 месяцев назад +1

    nice work. can you think of a way to do a change over time between several colors? not only 2? im thinking about something like in the particles engine.

    • @jonbednez
      @jonbednez  7 месяцев назад

      good question! are you looking to modify the current script from this video? if you are referring to the particles system, what you could do is use 'Color over Lifetime' and have several color keys, using 'Blend'.

    • @ShacharOz
      @ShacharOz 7 месяцев назад

      @@jonbednez no. i want to use the same method for another object. lets imagine you want to change between 10 colors according to some conditions. and not to create a fade between original color and a second one, as you did in the video.

    • @jonbednez
      @jonbednez  7 месяцев назад

      @@ShacharOz the method being Color.Lerp? like I click an object, lerp to red. when I reach a trigger, lerp to yellow. this random condition, lerp to another color, etc. OR lerp from yellow to red to orange to whatever color you want, like a rainbox highlighter? or something completely different? are you using a color array? a random color? thanks for your questions.

    • @ShacharOz
      @ShacharOz 7 месяцев назад

      @@jonbednez ok thats a nice idea, to use an array of colors, which in my case, might do the job.
      although I was thinking that a rainbow type of interface, with a user interface similar to the one on the prefab mechanism would be more effective.
      what I want to create is a sort of daytime-nighttime sun controller, which not only changes the location and direction of the sun, but also changes the color and light intensity of the sun.
      the time of the day should be shorter than 24hours of course. nd this should be a parameter.
      but all the rest of variables could be pre-selected.
      but if user would like to change the color of the sun, they should be able to influence that.

    • @jonbednez
      @jonbednez  7 месяцев назад

      @@ShacharOz To change the color of the sun, you could use a color picker. maybe something like this from the asset store -> assetstore.unity.com/packages/tools/gui/flexible-color-picker-150497. you could use the output to change the color of the directional light (if that's your sun)?
      With Color.Lerp, you can use a tick increment instead of the PingPong. currentTime += (Time.deltaTime * LerpSpeed); lerpedColor = Color.Lerp(Colors[0], Colors[1], currentTime);