Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // calcualte position difference (a.k.a. tangent vector):
- var dx = enemy.x - x;
- var dy = enemy.y - y;
- // calculate angle in radians of instance:
- var rad = degtorad(image_angle);
- // calculate where is instance right side (a.k.a. binormal vector):
- var bx = -sin(rad);
- var by = cos(rad);
- // calculate on which side of instance enemy is (1 - on the right; 0 - directly in front; -1; on the left):
- var side = sign(dot_product(dx, dy, bx, by));
Add Comment
Please, Sign In to add comment