- Home /
How do I turn off all light (for complete darkness)?
I am using unity for the first time and as a sound designer am not familiar with game engines (anything outside of audio really!).
I'm creating a game which uses audio as a navigation tool, and varies the amount of vision (using spot lights as the main source of light).
How would i turn off the main light completely, and implement spotlights which can be triggered on and off?
thanks
Answer by KoJix · Jun 01, 2015 at 02:39 PM
You can go to Edit>Render Settings and set the Ambient Light color to Black. This might work for what you're making.
The Spotlights can be triggerd by code. http://docs.unity3d.com/ScriptReference/GameObject.SetActive.html http://docs.unity3d.com/ScriptReference/Light.html
Great thanks a lot, been stuck on this for too long! New to coding, but i'll give it a go.
Is coding the only way to trigger spotlights? I have previously used Sphere colliders to trigger audio components, can the same be done with lighting?
Thanks
You can work with trigger colliders yess.
You can do a simple code like:
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : $$anonymous$$onoBehaviour {
public GameObject spotlight;
void Start () {
spotlight.SetActive (false);
}
void OnTriggerEnter(Collider other){
if (other.tag.Equals ("Player")) {
spotlight.SetActive(true);
}
}
void OnTriggerExit(Collider other){
if (other.tag.Equals ("Player")) {
spotlight.SetActive(false);
}
}
}
But this might be to simple for what you're making
Your answer