I wrote a simple script to display the values returned from boundingBox (see attached).
BoundingBox values for a car object:
minX= -1.62568
minY= -2.64179
minZ= -1.75382
maxX= 1.62568
maxY= 2.64179
maxZ= 1.75382
BoundingBox values for Barracks object:
minX= -8.28908
minY= -3.8812
minZ= -2.78802
maxX= 8.28908
maxY= 3.8812
maxZ= 2.78802
It appears the positive max values are the simple dimensions of object (i.e, the car is 1.6 meters wide, 2.6 meters long, and 1.7 meters high).
For the Searchlight LOS script, it is reasonable to assume that all objects are set at ground level. You can then check the height (maxZ) value of each object that is in the LOS path from searchlight to target. If the object height is > X, then the searchlight loses the target.
That would be a good start, but not perfect. As it would not solve:
- How far is the object's center from the LOS line? If center is too far too left or right, and the object is not wide/long enough, then target might be visible, but script based on height alone would not know it.
- What dir is object facing? Target is more likely to be obscured if behind long side of car (length), rather than short side (width).
But it seems possible to dial all that in with further math and logic.
A final hassle would be dips in terrain, but I remember reading somewhere that somebody was handling that somehow, or at least discussing it.
Edit: Good luck Blanco. This is a worthwhile script. Having a searchlight behave smartly will be awesome for immersion. Adding voice files for detection, evasion, etc. would be fun too: "Target spotted!", "Lost him behind the building!", "Check around those bushes!", "Behind the wreck!", etc.
After spotting target, then losing him, a behaviour to scan the immediate area where target was last known, getting slowly wider and wider would be cool (before switching to default search pattern).