Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool isWithinAngle(Vector2 playerPos, float playerRotation, Vector2 checkPos, float maxAngle)
- {
- Vector2 difVector = playerPos - checkPos;
- float radRotation = (float)Math.Atan2(difVector.Y, difVector.X);
- float degRotation = MathHelper.ToDegrees(radRotation);
- if (Math.Abs(degRotation - playerRotation) < maxAngle)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
Add Comment
Please, Sign In to add comment