I'm trying to do cone of sights this way: I've got a PLAYER and an ENEMY. This line of sight is to determine weather or not an ENEMY is visible to the PLAYER.
Always
- PLAYER alterable value A = the angle the player is currently looking in
- ENEMY alterable value A = the angle from PLAYER to ENEMY
So, ignoring obstacles and stuff:
ENEMY alterable value A - 45 < PLAYER alterable value A
ENEMY alterable value A + 45 > PLAYER alterable value A
- ENEMY is visible
Problem?
ENEMY alterable value A = 0
PLAYER alterable value A = 350
technically the enemy should be visible but according to the formula, it isn't. I've thought about using radians but my head started to hurt. Anyone have an elegant solution to this?
Hmm, off hand, I'd say wrap the player/enemy angle value around after it's more than 180 degrees off from each other. I assume you're fastlooping these events, because you'd need to check each enemy individually.
Hey, Jerry, here is the easiest solution I can think of. Add these two events (or use the new OR function on the latest build of MMF2):
ENEMY alterable value A< PLAYER alterable value A + 45 + 360
ENEMY alterable value A> PLAYER alterable value A - 45 + 360
PLAYER alterable value A< 45
- ENEMY is visible
ENEMY alterable value A< PLAYER alterable value A + 45 - 360
ENEMY alterable value A> PLAYER alterable value A - 45 - 360
PLAYER alterable value A> 315
- ENEMY is visible
If you want I could add a whole mathematical story to your problem and solution, but I'll spare you that.
(Edit: fixed stupid typo)