Hello i’m trying to learn how to program a cube to change colors from white to any color like black or blue to going back to the color.
This is the code for the color cube:
I’m supposed to use arrays in there too, I’m puzzled right now
Hello i’m trying to learn how to program a cube to change colors from white to any color like black or blue to going back to the color.
This is the code for the color cube:
I’m supposed to use arrays in there too, I’m puzzled right now
You might want to take a look at iTween ( http://itween.pixelplacement.com/ ).
Its free and handles all kinds of tweening operations including colour.
I kinda meant to program it in C#, i’m a beginner level programmer trying to code it from scratch.
Based on the docs found here: Color.Lerp
using UnityEngine;
using System.Collections;
public class ColorLerp : MonoBehaviour
{
void Update()
{
renderer.material.color = Color.Lerp(Color.blue, Color.white, Mathf.PingPong(Time.time,2));
}
}
Look through the documentation as there are several useful examples.
It works, But i wanted to program in a way where it change colors back and forth when i click it
I want to be able to Program it from:
Change it from White to Black and vice-versa
Use arrays to program it colors