- Home /
How to make a lot of light blinking ?
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 ?
Answer by tanoshimi · Sep 27, 2013 at 05:12 PM
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.
Answer by cappie013 · Sep 27, 2013 at 06:04 PM
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/
(I think what you've just wrote was meant to be a comment, not an answer. And, for future reference, it's helpful when you're trying to copy the effect of something else if you write that in your original question... ;)
I see nothing in that demo that receives variable lighting or casts dynamic shadows. All I see is some textures that have emissive properties and a glow post-process effect. So I don't think you mean "lights" at all. You just want a surface shader that exposes the emissive property of a material that you can control from script, using a ti$$anonymous$$g loop similar to that I posted above.
Your answer
Follow this Question
Related Questions
How to properly light interiors 0 Answers
lightmapping 1 model in different scenes 1 Answer
Why realtime and lightmapping results so different? 1 Answer
Unity 5 lightmapping issue. 0 Answers
Lightmapping Darkness & Lightmapped Hard/Soft Shadows 0 Answers