Search Unity

Resolved Field Of View For Enemy not working

Discussion in 'Scripting' started by macdonaghpm, Nov 28, 2022.

  1. macdonaghpm

    macdonaghpm

    Joined:
    Apr 26, 2021
    Posts:
    63
    I used a video by code monkey to implement pathfinding in my game. It is the one for backstabs.
    Code (CSharp):
    1. if (Vector3.Distance(transform.position, player.position) < playerNoticeDistance && dot > 1 - noticeDotOffset)
    2. {
    3.      head.LookAt(player);
    4. }
    The problem is that it doesn't work if my enemy is rotated at a different angle and I am not sure how to account for it.
     
  2. macdonaghpm

    macdonaghpm

    Joined:
    Apr 26, 2021
    Posts:
    63
    nvm