Search Unity

Directional Light Rotation Script

Discussion in 'Scripting' started by Velketor, Apr 7, 2008.

  1. Velketor

    Velketor

    Joined:
    Sep 15, 2007
    Posts:
    110
    Hello,

    I am trying to have my directional light raise and lower based on the players movement/speed. If the player runs faster, the directional light rises dynamically and vice versa.

    Here is the script I currently have attached to my character controller:

    Code (csharp):
    1.  
    2. var deltaAngle : float = 1.0;
    3.  
    4. function Update () {
    5.     // is the player trying to move?
    6.     if (Mathf.Abs(Input.GetAxis("Vertical")) > 0) {
    7.                 light.transform.Rotate(Vector3.up,deltaAngle * Time.deltaTime);
    8.     }
    9.     // do nothing if the player is neither accelerating nor decelerating
    10. }
    11.  
    Can anyone edit this script or point me in the right direction toward getting the my Directional Light to dynamically rotate as the player moves?

    Thanks!

    --Velk