Field of Vision obstructed when colliding w/ a gameobject


This image explains what I want in a nutshell for a unit in an RTS

Essentially, the Field of Vision gameobject in the image would have a script attached to it that morphs shape when it runs into a new gameobject.

I have no idea how to code this script. It emulates what a person’s field of vision would look like if he looked at a wall. He cannot see through the wall so his field of vision shrinks slightly.

Here is what the field of vision would look like with no obstruction.

@MJMC brought up a good point so I must add that:

  • the player can see the other side of obstructing gameobject, but the gameobject cannot. Think of a unit from Command and Conquer or Starcraft.
  • the field of view gameobject must be able to detect collisions.

Tutorial link : Field of view visualisation (E01) - YouTube
Note: I think the title for this question is horrible! Suggestions welcome :slight_smile:

Of course it is horrible :slight_smile:

Do you want to see the other side of the wall? If yes you can add a second camera a little bit ahead of your main camera and deactivate it, after reaching to the wall you can deactivate first camera and activate second one.

@SebastianLague This two-part tutorial is above and beyond what I wanted. No cameras needed, only some slick trigonometry which Sebastian does for you.

Part 1(basics)

Part 2 (more making the field of vision visible)