Guest User

Untitled

a guest
Oct 17th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. // calcualte position difference (a.k.a. tangent vector):
  2. var dx = enemy.x - x;
  3. var dy = enemy.y - y;
  4.  
  5. // calculate angle in radians of instance:
  6. var rad = degtorad(image_angle);
  7.  
  8. // calculate where is instance right side (a.k.a. binormal vector):
  9. var bx = -sin(rad);
  10. var by = cos(rad);
  11.  
  12. // calculate on which side of instance enemy is (1 - on the right; 0 - directly in front; -1; on the left):
  13. var side = sign(dot_product(dx, dy, bx, by));
Add Comment
Please, Sign In to add comment