Created
October 13, 2012 22:25
-
-
Save brunokruse/3886414 to your computer and use it in GitHub Desktop.
Light Pulsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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