Skip to content

Instantly share code, notes, and snippets.

@brunokruse
Created October 13, 2012 22:25
Show Gist options
  • Save brunokruse/3886414 to your computer and use it in GitHub Desktop.
Save brunokruse/3886414 to your computer and use it in GitHub Desktop.
Light Pulsing
#pragma strict
var duration : float= 2.0;
function Start () {
}
function Update() {
// argument for cosine
var phi : float = Time.time / duration * 2 * Mathf.PI;
// get cosine and transform from -1..1 to 0..1 range
var amplitude : float = Mathf.Cos( phi ) * 0.5 + 0.5;
// set light color
light.intensity = amplitude;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment