2D Collider Trigger cutoff at walls?
Good afternoon. This is my first post so apologies if I've labeled something wrong or missed something. I'm a beginner with Unity and I was hoping to understand how to accomplish this:
I currently have an enemy that is patrolling with this red trigger 'detection'. The radar is attached to the enemy and has a polygon collider 2d shaped closely around it. My question is it possible to somehow chop off the trigger collider (and the cone visual) as it reaches the wall to prevent it from detecting on the other side of the wall? I know I can probably layer it so the cone is beneath the tilemap, but I know it'll still show up on the other side.
My goal is to prevent future problems where if there's platforms on the other side of the wall I do not want the player to be detected. I really would appreciate any input on a way to tackle this.
Answer by Aavacado · Aug 07, 2020 at 09:31 PM
I think my answer is using meshes with raycasts as shown in Code Monkey's youtube video about Cone Line of Sight effect. I'm going to try that, but I'm guessing it'll be difficult to add the red outline. Not sure how to accomplish that.