I want to check if a unit is within view of a cameras field of view to determine which units I can see and which ones I cannot. Please note: I'm using CameraForceMouseRelative(Player, true) and CameraSetMouseRotates(Player, true) so the player can move the camera in a 360 view.
You will need to use the "Convert Rectangle to Region" condition and adjust the parameters to meet the camera's properties. It will require intense maths, so unless you're prepared to deal with that I would advise finding another way to do what you want to do.
With a real 360 view, there's no approximate shortcut with regions... besides, the frustum isn't a planar rectangle or circle anyway.
Matrix 3d projection math would seem to do the trick "easily", but it's not like we can extract the projection matrix and the 3d world position of actors. I'm not even sure you could recompute the projection matrix used internally by the engine, given there will always be some unknowns like the aspect ratio...
I'll agree with BasharTeg on that, try to find another way to do what you want to do.
Right, as long as the player is looking at least slightly downward it should work, but looking straight up will cause problems. So it may not be worth attempting anyway.
Edit: Ignore this. I'm just leaving this here while I finish some other work and run tests first before I post this.
I may have mislead with saying 360 view? The camera is free to move wherever but the cameras view itself is your basic box. The camera is always centered in the middle of the map and doesn't move, but the player can rotate/free-look around. Assume I'm using a 64x64 map and the cameras is at the center of the map at x32y32z0. Using a 360 degree sphere with a size of 32xyz, can't I do something like CenterOfMap(x32y32) +
I want to check if a unit is within view of a cameras field of view to determine which units I can see and which ones I cannot. Please note: I'm using CameraForceMouseRelative(Player, true) and CameraSetMouseRotates(Player, true) so the player can move the camera in a 360 view.
You will need to use the "Convert Rectangle to Region" condition and adjust the parameters to meet the camera's properties. It will require intense maths, so unless you're prepared to deal with that I would advise finding another way to do what you want to do.
With a real 360 view, there's no approximate shortcut with regions... besides, the frustum isn't a planar rectangle or circle anyway.
Matrix 3d projection math would seem to do the trick "easily", but it's not like we can extract the projection matrix and the 3d world position of actors. I'm not even sure you could recompute the projection matrix used internally by the engine, given there will always be some unknowns like the aspect ratio...
I'll agree with BasharTeg on that, try to find another way to do what you want to do.
@StragusMapster: Go
Right, as long as the player is looking at least slightly downward it should work, but looking straight up will cause problems. So it may not be worth attempting anyway.
OK. I'll have to think about it for a while.
Edit: Ignore this. I'm just leaving this here while I finish some other work and run tests first before I post this. I may have mislead with saying 360 view? The camera is free to move wherever but the cameras view itself is your basic box. The camera is always centered in the middle of the map and doesn't move, but the player can rotate/free-look around. Assume I'm using a 64x64 map and the cameras is at the center of the map at x32y32z0. Using a 360 degree sphere with a size of 32xyz, can't I do something like CenterOfMap(x32y32) +