So maybe the tracker shouldn’t be an actual object attached to the target?
Maybe you could put it on an overlay scene, like the HUD it is (supposedly) meant to represent?
The question is:
To be honest, I haven’t done this one in particular, but I do know there are some handy functions for it.
For example, You can check if an object is visible with:
camera = bge.logic.getCurrentScene().active_camera
visible = camera.pointInsideFrustum(object.worldPosition)
Note that this looks at the center of an object. Investigate the boxInsideFrustrum or sphereInsideFrustrum
And one can get the screen-space location of an object with
x,y = camera.getScreenPosition(object)
Now you’ll have to do something with the X and Y co-ordinates. While the document doesn’t explicitly say so, I’d guess they run from -1 to 1, or maybe 0 to 1. Either way, you should probably multiply x by bge.render.getWindowWidth() and y by bge.render.getWindowHeight() (this will correct aspect ratio).
Finally you should set an object on an overlay scene to this position, with something like:
HUD_MARKER.worldPosition = [x,y,0]
And have a camera looking down at it.
But yeah, that’s the complex way. The script you’re looking for probably goes like:
scale = camera.getDistanceTo(obj)**0.5
obj.worldScale = [scale, scale, scale]
Not quite sure if that should be **0.5 or **2. Too tired to think it through fully right now.
Good Night.