It's 1.00 am and I'm tweeking around with the test A.I. Here's the idea for the light system:
- Player has a flashlight
- Flashlight emits light (wow!)
- Invisible particle system parented to the flashlight
(emits particles to the same area that the light hits)
- If particles hit the collider of the enemy, enemy attacks
I have it working now like that when a particle hits the enemy, it prints text.
So next thing is to figure out how to make the enemy attack / follow the player.
First idea was to raycast, but the problem was that it would require shooting multiple rays and therefore more code. Invisible cone mesh over the light was another idea, but again, that wouldn't be accurate and would require figuring out how to not react to enemies behind walls.
Particles will bounce off walls and also when they bounce if you point the flashlight to a room from a corridor, its quite likely that a particle will hit the collider of the enemy hiding in there, which is just the thing im after.. The enemies should react also to light that gets close to them / they can see. Not only the light that hits them directly..