Advertisement
tahg

Untitled

Oct 14th, 2019
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. Assume p=player, e=enemy, r=enemy rotation (eg 0-359) with 0 at +x and going towards +y
  2. d=(cos(r), sin(r))
  3. pd=(p.x-e.x, p.y-e.y)
  4. pdn=pd/sqrt(pd.x*pd.x+pd.y*pd.y) OR pdn=normalize(pd) Direction to player, normalized
  5. dot=pdn.x*d.x+pdn.y*d.y OR dot=dot(pdn,d)
  6. 1 = enemy is perfectly looking at player
  7. 0 = enemy is looking sideways from player
  8. -1 = enemy is perfectly looking away from player
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement