[Help] Writing a Field Of View scanner
As you probably know I maintain an advanced mob mod called Creatures. Despite mobs being almost feature complete, there's one more thing I'd still like to add: Field of view simulation. Currently mobs can see people who are behind them, and that's obviously not very realistic... we want them to only notice targets within their field of perspective.
Problem is that I'm not sure what formula I should write up to fix this. Basically I work with the following parameters: position1 (the mob's location), yaw1 (the mob's rotation), fov1 (the mob's field of vision in degrees), position2 (the target's location). How would I be able to determine if at rotation yaw1, through the focal length fov1, position2 can be seen from the perspective of position1? Basically compute the virtual cone from position1 and know if position2 is within it.
I imagine it's not a very complex formula, but still more than my mind can work out on its own right now. If someone with a more functional brain could offer one, that would be very appreciated!
Problem is that I'm not sure what formula I should write up to fix this. Basically I work with the following parameters: position1 (the mob's location), yaw1 (the mob's rotation), fov1 (the mob's field of vision in degrees), position2 (the target's location). How would I be able to determine if at rotation yaw1, through the focal length fov1, position2 can be seen from the perspective of position1? Basically compute the virtual cone from position1 and know if position2 is within it.
I imagine it's not a very complex formula, but still more than my mind can work out on its own right now. If someone with a more functional brain could offer one, that would be very appreciated!