Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Duplicating Cameras, problem since cant create layer

Discussion in 'Scripting' started by sildeflask, Oct 2, 2023.

  1. sildeflask

    sildeflask

    Joined:
    Aug 16, 2023
    Posts:
    142
    I need to duplicate cameras and objects.

    Each duplicated object needs to be seen only by its respective duplicated camera.

    I could do this if I could create new layers through script and set them on the new duplicated camera culling mask.

    However it seems layers cant be created during runtime.

    How to solve this? Lets assume a situation where I instantiate 1000 cameras and each camera looks at their respective 1 out of 1000 objects.

    No need to raise concerns of performance, just wanted to know if possible or not, thanks!
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
    Not as you describe it here no, but if I follow you, you could have 1000 additive scenes each with its own camera and just share the layers (keep them the same). Each camera would need to be instructed to only render a specific scene by using: https://docs.unity3d.com/ScriptReference/Camera-scene.html

    I can honestly say that I've not thought long and hard about what I just said so may have terrible flaws. ;)
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Put them in 1000 different places (in space) and set the view frustums up so they're small enough they don't interfere. See below.

    Multi-camera multi-layer (and even multi-light) stuff is for things that are all colocated, such as using it to get ground cursor highlights on an RTS game by using multiple layers.



    https://forum.unity.com/threads/how-to-write-text-on-sphere-on-runtime.1381764/#post-8703084
     
    sildeflask likes this.