Street lamps and lighting is ready!

Today I have been working in modeling some kind of a future street lamp, when I finished I created the .fbx and imported into unity, then I integrated the street lamps intro the tiles and developed a short script to be able to switch on and off the lights.

3dmax2
Caption 1. The street lamp in 3d Studio Max.

One of the main problems is that because of the high amount of lights in the game, the performance is not so good, so I will try to evade that night lighting or at least to restrict it a bit. In the next video you can see how the lights are switch on and off. I also introduced a movement camera but is it not the final one, just to be able to explore my city in real time.

To achieve that I created a script with a function that checks if lights are on or off and switch it on or off depending on the call. To do that I just search for all the lights in the scene and change the value of the intensity of the light component as it can be seen in this code:

auxGameObjects = GameObject.FindGameObjectsWithTag(“NightLights”);

GameObject.Find (“MainLight”).GetComponent<Light> ().intensity = 0;

foreach (GameObject aux in auxGameObjects) {
                aux.GetComponent<Light>().intensity = 0.78f;

}

In that case it search for all the objects with the tag “NightLights” and the object with the name “MainLight”, then it change the value of the intensity of each object depending if it has to be on or off. In that case is the night version, so the main light is turned off and the street lamps are turned on. 

 

 

Leave a comment