Ich versuche, die Hintergrundfarbe der Kamera zwischen zwei zufällig ausgewählten Farben zu ändern. Ich habe das schon erreicht, aber dann habe ich festgestellt, dass es immer einen Blitz gibt, wenn eine neue Farbe ausgewählt wird. Ich habe ein Video des Problems auf diesem link hochgeladen. Und das ist das Skript, das ich gerade verwende:Ändern der Kamera Hintergrundfarbe nach dem Zufallsprinzip Überstunden
public Color color1;
public Color color2;
float time;
float time2;
float transition;
int firstColor = 0;
void Update()
{
if (firstColor == 0)
{
color1 = Random.ColorHSV(Random.value, Random.value);
color2 = Random.ColorHSV(Random.value, Random.value);
firstColor = 1;
}
Camera.main.backgroundColor = Color.Lerp(color2, color1, transition);
time += Time.deltaTime;
time2 += Time.deltaTime;
transition = time2/5;
if (time > 5)
{
color2 = color1;
color1 = Random.ColorHSV(Random.value, Random.value);
time = 0;
time2 = 0;
}
}
Jede Hilfe wird sehr geschätzt.
Das ist so ein toller Code, danke für die Erklärung. –
Gern geschehen! – Programmer