For my first game, I try to make my game reacting to a specific music. To do this, I want to create a lot of light and make them blinkings. I try to create two differents lightmap and switch between them, but this doesn’t seem to work.
Any lead to help me ?
You can set the intensity of each light (and other properties - their colour, range etc.) programmatically through script. For example, attach the following C# script to a light object to make it pulse every second (or whatever value you set “duration” to be):
using UnityEngine;
using System.Collections;
public class BlinkingLight : MonoBehaviour {
public float duration = 1.0F;
// Update is called once per frame
void Update () {
float phi = Time.time / duration * 2 * Mathf.PI;
float amplitude = Mathf.Cos(phi) * 0.5F + 0.5F;
light.intensity = amplitude;
}
}
To sync this to music instead, you might want to make use of this code.
The number of lights who can be rendered is limited, isn’t it ? So, if I’ll have 20 on my screen, your code won’t work. I want to reproduce the effect in this game : http://hellorun.helloenjoy.com/