- Home /
Detect GameObject Blocked
I made a model that can be dragged and rotated with mouse. And then I add some tag to the model. So whenever the model rotate, the tag rotate with it. I wonder how we can detect if a tag is rotated behind model. The tag is invisible from the camera view, because it is blocked by other object. Is there a function I can use or is there a common way to check that?
I am new to unity3d. Thanks for helping me out.
well, thanks Noah. I think I didn't make myself clear. I try to detect if the tag is visible from the camera, whether there is other object block (occlude) the tag.
I did a little search, it seems to be an issue since unity does not have build in function for it. OnBecameVisible, OnBecameInvisible don't serve the purpose.
Well, can you explain why OnBecameVisible and OnBecameInvisible doesn't work in your case, because these events do exactly what you described. Do you want to know when it's partially occluded? $$anonymous$$aybe just tell us what's the desired end result you want to achieve. What exactly is your "tag"? I'll guess another GameObject?
Thanks Bunny. Yes, "tag" is another GameObject. I want to detect if one gameobject is behind another one, so it is not visible from the camera, like an total solar eclipse. To my understanding, onBecameVisible is always true in this situation because the GameObject behind might cast shadow or reflection on the one in the front, and therefore it is rendered. So OnBecameInvisible cannot be triggered.
Your answer
![](https://koobas.hobune.stream/wayback/20220613113103im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is there any way to hide only part of an object from the camera? (unity free) 2 Answers
CalculateFrustumPlanes not working 1 Answer
Hide a light for a camera 2 Answers
GameObject and Camera visibility 1 Answer
Camera that sits behind player 2 Answers