Hello!
I have been trying to prototype a light-based stealth mechanic for a project I am working on.
The idea is that the player in the dark would not be visible, while in the light would be visible. I would like to read the light value from the model / mesh to be as accurate as possible. Preferably sample a few points to determine how visible the player is. I need this value so enemies can detect if the player is in the light long enough to be spotted.
I know there are other ways of doing this:
- Using Collisions and detecting if the player is in a visible area
- Creating a table and storing light positions / ranges then checking player brightness with proximity
Before I explore other options, I would prefer to use the actual alpha color value stored in the model / mesh since that seems like the most straight forward.
Is this something that is possible?
Is there a better or easier way of doing this?
The lighting I am using is the simple 2d light by britzl
This is what I am thinking of.
In Darkness:
Semi illuminated:
Fully lit:
Any ideas or code I could use would be extremely helpful.
Thank you!