- Home /
Visible GameObjects for AI
I'm trying to get a list of gameobjects that are currently visible in the first-person camera and pass these to a script for parsing by my AI. I don't want objects that are being completely occluded, so I started by determining if an object is within the camera's bounds and then performing a raycast to make sure it isn't occluded. The problem is that this causes some objects that are less than half-visible to not be returned.
I imagine this is because the raycast is going from the camera to the center of the target object and if the center is occluded (even if an edge isn't) then the raycast fails.
I've tried getting the bounds of the target gameobject (render.bounds) and then raycasting to the edges, but of course this is a bounding box and causes failures with non-square objects.
Does anyone have any good ideas on how I can solve this?
Your answer
Follow this Question
Related Questions
Problems with raycast obstacle avoidance 1 Answer
AI Avoiding Obstacles Problem 1 Answer
AI create path, help. 1 Answer
How can I find if a raycast has passed through two points? 2 Answers
Why Do Raycasts Ignore NavMesh Agents 4 Answers