Hi, I’m currently trying to pull off enabling a renderer of an object when it’s in line of sight of the object. I wouldn’t really know how to pull this off. I’ve tried Raycasting which still seems like the most plausible salution, but I can’t get it to cast in a 360 radius. Does anyone encountered the same problem before?
Example:
Left: Blue square is the player, enemy currently not visible.
Right: Enemy is now visible.
You shouldn’t need to cast 360 - just cast from the player’s position to the enemy’s position and see if you get there (hit the enemy, not something else first).
orgin: one of the 2 squares, the square u didnt chose shall be named “othersquare”. Now the direction will be: othersquare.transform.position - transform.position.
Now just do a Physics.raycast check, if thr raycast returns anothet object than the othersquare, disable the renderer!
Ps: sorry i coulnd write the code im on my train back home, typing on my phone