I’m making game where it’s pitch black and you need spotlights to see the platforms, but you need certain colored spotlights to allow you to see certain platforms (I’m using the culling mask technique). What if I want an object to be revealed ONLY when TWO different light sources shines on the same surface?
Bonus points if there’s a way to block certain light from passing through assigned transparent objects.
if you are using spotlights, you can just raycast from spotlights then check if both hit that hidden platform, if yes you can enable its renderer component.
here some documentation for you : Raycast Scripting Referance , Offical Raycast Tutorial and here is Mesh Renderer Manual
I hope this helps, if you need more explanation, just let us know. good luck.
Before I examine closely though, is this implying that if the lights are hitting ANYWHERE on it, then it will show? Because I’m referring to instances where the player needs to combine both red and blue spotlights to form magenta where the two meet. It should ONLY be where the magenta is formed that illuminates the platform.
It’s basically trying to have an object that only receives light from two combined spotlights. An ‘IF AND’ lighting if I’m making sense.
I think I know what you’re talking about, I played a game on my Wii that had the same type of thing in it, called Liight (two ii’s).
Also reminds me, to a lesser extent, of another Wii-Ware game called Lit.
Both were Wii-Ware demos, check them out at:
Liight: Liight Review (WiiWare) | Nintendo Life
Lit: LIT Review (WiiWare) | Nintendo Life
One easy way is to ‘un-hide’ the platform just before you turn the 2nd (required) light on. Basically, do a check at the start of the function you use to turn the lights on. Before turning a light on, see if the other light is on already, if so then make the platform visible(SetActive) and turn on(enable) the 2nd light at the same time.
There are always different ways to accomplish the same task in coding, so experiment with different methods. You could also have a script on the platform that would check if those two lights were both on, and if so, it makes it self visible and enables it’s collider(s). But to do a great effect you might want to look into Shaders in Unity, they can do all sorts of things. Maybe custom-rendering in Unity to only render parts of the object that are being lit by a certain light? Is that possible in Unity?