Advertisement
NPSF3000

GlowEngine

Jul 27th, 2011
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mainCamera : Camera;
  2.  
  3. var value;
  4.  
  5. function Start()
  6. {
  7.  
  8. if (mainCamera == null)
  9.         mainCamera = Camera.main;
  10.  
  11.     //this ignores the value set in inspector - makes bulk setting easier.
  12.     value = 0.05;
  13. }
  14.  
  15. function Update ()
  16. {
  17.         if(mainCamera)
  18.         {
  19.                 var heading: Vector3 = gameObject.transform.position - mainCamera.transform.position;
  20.                 var dot: float = Vector3.Dot(heading, mainCamera.transform.forward);
  21.                 gameObject.GetComponent(LensFlare).brightness = (value/dot) * transform.lossyScale.magnitude;
  22.         }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement