- Home /
Help 3D Enemy Detection Visual Feedback
Hello, all of you. I need to develop a detection system for a game boss I'm working on. He sees in a cone originated in his head, if the player enters into that cone, he is seen. Things to consider:
-If a player is behind an obstacle, he is not seen.
-There's variation in terrain elevation, so if he's looking for something on top, he doesn't see below, and vice-versa.
Programming this system is easy, but I need a visual indicator of where the boss is looking at. If I put a spotlight on his head, there's a light intensity variation for things closer or farther apart, and I need that indicator to be uniform.
If I use projectors, the projectors render in meshes behind the obstacles too, which cannot happen.
This height variation of terrain that prevents me from using the great solutions I've found.
I tried to find a way to leave the intensity of uniform light everywhere it reaches, or that projectors do not render behind the first object that it encounters, but without success.
Does anyone have the answer to these problems or other solution?
Thank you so much. And I'm sorry if it was hard to understand, English is not my main language.
This asset should do the visuals nicely for you - https://assetstore.unity.com/packages/vfx/shaders/volumetric-light-beam-99888
Answer by Mouton · Sep 27, 2019 at 07:39 AM
Use a mesh with a cone shape, attach it to the head of your animated model and use a semi-transparent material. This should do the trick.
Alternative
If you need to display the boss sight area on the ground so the player can avoid it you will need to project it onto the ground and concerned objects.
Look at this discussion on the forum on how to implement this solution (look at chris64 answers): https://forum.unity.com/threads/rendering-an-aoe-area.112163/
The problem in this solution is that some things on the scene blocks the boss vision. I would need something to make the projector not render in some areas inside his vision, like some type of mask. I can't find something of the sort.
If you need the area take in account the environment, you can either write a shader that takes in account obstacles, or use a particle system with collisions enabled.
Answer by akaBase · Sep 27, 2019 at 09:59 AM
When I was researching a similar issue I came across this tutorial showing how to create a FOV systsem using Raycasting which i think is exactly what you are after.
Unfortunately this doesn't work because the height variation of terrain.
Then add the 3rd dimension to it by adding top and bottom Rays with the gap inbetween middle and either side no more than the $$anonymous$$ height of the player.
See attatched image.
Answer by celrackov · Oct 04, 2019 at 11:06 AM
There is a site called livebook where I read an article dedicated to your question. Tr to find it there