0
\$\begingroup\$

I am currently working on a game that has monitors showing the player different elements such as texts, images and numbers. My plan for this is to use Unity's RenderTextures.

However, when creating the elements that the camera should put on the RenderTextures, they also exist in the scene.

What is the best way to hide them from the player? (Putting them far away or below the ground is not an option in my case).

Is there a way to put them in an entirely different scene for example?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Use layers.

By setting a culling mask on the player's camera, you can ensure it does not see the layers containing objects you want to hide.

By unchecking layer interactions in the physics collision matrix, you can ensure that the hidden objects won't process collisions with objects on other layers, so they'll just ghost through each other without sending OnCollisionEnter messages and the like.

You can also use layer masks to exclude these layers from your raycasts or other physics queries.

Together, these features effectively put those objects in an unseen parallels universe, even if they are close by in coordinates.

You'll want to avoid moving objects too far away from the origin, due to limited floating point precision.

You can also put these objects in a separate scene file for ease of editing them in isolation, and use additive scene loading to load that scene and others at the same time. This does not automatically separate them for rendering and physics interactions, so you still need to use layers as described above.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .