- Home /
Camera.main - what does this mean in a split screen game?
I am experimenting with split screen. Obviously, I have to make script agnostic from any "Camera.main" calls, because that would be ambiguous.
But in the case of things like procedural ribbon trails, it's important to orient faces toward the current rendering camera.
Normally, I am constructing geometry to face the camera inside of Update. I would assume that this is called just once, regardless of the number of cameras rendering concurrently.
Have I completely missed that there's already a "Render" function, called before each camera renders? If there is, obviously, the geometry generation would be more appropriate here!
When calling Camera.main from within such a call, I assume it would point to the current rendering camera?
Answer by Aubrey Hesselgren · Sep 30, 2010 at 09:46 AM
Answering my own question!
Use "OnPreRender()" to set up the geometry. This will do it per camera, as it gets ready to render (as the name implies)
Then, instead of using Camera.main, use Camera.current.
HOWEVER "This function is called only if the script is attached to the camera and is enabled.", so, in my case, I must put a script on each camera which triggers any ribbon scripts to re-generate their geometry. I can't put "OnPreRender()" on the ribbon script itself. Oh well.
Damn I love unity! Sorry for spamming the board. Sometimes it just helps to voice an issue. Hope it's useful to someone else!
Your answer