- Home /
How to detect if a game object is visible by a certain camera
I want the player to hold a button and it completes a progress bar while holding and when the progressbar is complete the camera will scan and ping certain gameobjects within it's view, I want to detect certain gameobjects with specific tag to be detected, i want to detect the object only if it is visible in view for e.x: if a wall is in front of the gameobject, It shouldn't get detected, I have already implemented the hold button to complete progress bar mechanism, I just don't know how to implement the detection part,I want the player to hold a button and it completes a progress bar while holding and when the progressbar is complete the camera will scan and ping certain gameobjects within it's view, I want to detect certain gameobjects with specific tag to be detected, i want to detect the object only if it is visible in view for e.x: if a wall is in front of the gameobject, It shouldn't get detected, I have already implemented the hold button to complete progress bar, I just don't know how to implement the detection part
Answer by AlirezaSH2004 · May 19, 2020 at 01:34 AM
Hello there. You can use the built-in "OnBecameVisible" function:
void OnBecameVisible()
{
//Do something
}
The target game object should have a script on it containing this function.
Your answer

Follow this Question
Related Questions
Check if is object in camera field and not covered by other object 0 Answers
Unity wont detect device camera 0 Answers
Detect if player looks at an object? 1 Answer
Jittery Collision Detection 0 Answers
HELP. Camera Movement vs. NPC detection. 0 Answers