about raycasthit2D how to change from a line to an area?
Hello My Developer friends, I am using Raycasthit2D to define the radius of vision of the enemy, everytime the player collides with the raycast, the enemy follow the player,when the player leaves, the enemy stops, so far so good, but when the player jumps, he leaves the raycast and enemy stops and it is weird because everytime i jump the enemy stops, so how can I create a raycast that works in area, like a circle? it will help when the player jumps, because he would continue in the raycast area.
Answer by I_Am_Err00r · Aug 29, 2019 at 09:10 PM
You might want to try a circlecast instead of raycast: click here for more informaiton.
The problem with this is it will require something more elegant to check for walls, and if the player is behind a wall and still within range, the enemy will follow the player (which might not be desired).
If you want a paid asset that I use to slap these things together in about 30 seconds, I would really recommend this asset; it basically handles all the different casts, draws and diplays them for you, you can choose what layers to detect on and what layers block sight as well as set a minimum value for (example if you set minimum sight to 50%, it will trigger an event up until the player is at 49%).