Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Enemy view zone

Discussion in 'Scripting' started by terraKote, May 3, 2014.

  1. terraKote

    terraKote

    Joined:
    Apr 3, 2014
    Posts:
    9
    Hi everyone! Making 2D top down game, and I need to make a view zone for enemy. It has to be something similar for shadows. For example enemy cant see trough the wall, he's field of view has to be some king a 'cutted'. Was idea to make a plane, but don't know how to make it cut when enemy near the wall.
     
  2. UnityUser_721

    UnityUser_721

    Joined:
    May 3, 2014
    Posts:
    19
  3. Patico

    Patico

    Joined:
    May 21, 2013
    Posts:
    886
    In one of the projects I used such approach: Player has a trigger, when Enemy enter in the trigger Player detect him and calculate an Angle between own forward vector and vector towards to Enemy, after this all you need is to check if Angle in the margins and if there is not anything between Player and Enemy (for this Raycasting is the best way, I think).