I’ve done some searching but am yet to find a solution to this exact problem, so I’d love some tips or to be pointed in the right direction.
High concept of the issue: It’s a simple photography game, and I want to know how much of the object is on the camera (preferably as a percentage of the whole object).
Elaboration: There is an object on the screen, and I want to test how accurate the player has been in taking the shot. Most solutions simply check if the object is partially on screen, and that simply tells me some part of it is visible, but not whether it is completely visible or how much is actually on the screen.
This is a problem in two ways as a character a screenshot is taken of will be considered “visible” if their big toe is on the screen, and also perfectly visible if they are so close that only a single pixel of the entire character was on screen.
And it may be too much, but it would be great for the solution to be applicable to an object also being off camera because it is being blocked. So for example, a character could be partially off screen or partially covered by a wall, and the result is basically the same for what I need here. Attached is a photo showing the cut off (not sure if it helps much).
Current Work: I am currently using TestPlanesAABB to see if the collider is within the camera’s view, and that works fine. I have been attempting to use raycasts to the min and max bounds of the collider also, but this feels like a poor and ultimately limited solution to the problem as it only looks at two points of what could be a complex shape.
If you’d like my to elaborate on anything let me know.