Comments

  • The CanSeeAgent function returns true or false, indicating whether a specific NPC (represented by the Transform component) can see the player (an object tagged as, player). true means the player can be seen, and false means the player cannot be seen.
  • There are several steps to determining player visibility. The first is to establish a field of view for the NPC, that is, an angle threshold either side of the forward vector, representing the angular limits of view.
  • To determine whether the player is within the angular limits, the Vector3.Dot function is used. This function takes two vectors as input and returns information about the angle between the vectors, assuming that they were laid out from a common starting point.
  • If Vector3.Dot ...

Get Mastering Unity 2017 Game Development with C# - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.