- Home /
Lighting on only 1 camera
Hi all!
So i'm trying to get some lighting to only be visible on one camera. As my scene is quite dark the mini map camera needs an overhead light so that the player is visible. I've tried using this code:
using UnityEngine;
public class minimapController : MonoBehaviour {
public Transform player;
public GameObject miniCamLight;
private void OnPreRender()
{
miniCamLight.SetActive(true);
}
private void OnPostRender()
{
miniCamLight.SetActive(false);
}
private void LateUpdate()
{
Vector3 newPos = player.position;
newPos.y = transform.position.y;
transform.position = newPos;
}
}
But it doesn't seem to work, any help would be greatly appreciated!
Answer by Tomer-Barkan · Nov 16, 2018 at 01:32 PM
When selecting a light in the Scene, you can set a culling mask in the Inspector. Thit lets you determine which layers will be affected by the light. The same culling mask can be set in cameras, and tell them what to render.
As long as they are in sync, the camera will render the same objects that the light will affect.
BTW, for $$anonymous$$imap and such, consider maybe using an Unlit shader, then it won't need or use lights at all.
Your answer
![](https://koobas.hobune.stream/wayback/20220612182229im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
new project aren't set up right 1 Answer
game object appearing dark on one side 0 Answers
Circle artifact appears when camera follows player 0 Answers
Light glitch when not in camera's view 0 Answers