Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ozturkcompany · Apr 06, 2015 at 04:35 PM · collider

How to tell if an object that behind another object can be seen?

Hello, I am trying to find out how to check if an object that behind another object can be seen by camera. I figured out a way of doing it but it requires 32400 rays to be shoot out from the camera per frame which i think that is a lot of process to do. So what would be the easiest way to achieve this? What i've been thinking about for now is checking which object is behind another and then comparing the bounds of colliders of these two object and see if front object has a bigger collider so the object behind cannot be seen by the camera BUT this won't work if it is a complex geometry..Any ideas? Thank you in advance!

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Glurth · Apr 09, 2015 at 12:39 AM 0
Share

Can you fudge it? If so, you can use the object's renderer's bounds field (http://docs.unity3d.com/ScriptReference/Renderer-bounds.html) to get the 8 corners of the cube that contains the object. If a raycast to any corner does not hit another object, the object is NOT completely obscured, just partially obscured. If all 8 hit another object, it IS obscured. If all 8 dont hit another object, it is completely visible.

This is just a FUDGE tho; consider a sphere bounded by a cube, lots of empty space between the cube corners and the sphere surface, could lead to incorrect results.

Another, more exact method, I don't think you can do without unity pro. It involves rendering your scene to a texture rather than the screen. With this method you can render all your objects (without lighting) as say.. black.. except the object your want to detect- that one you draw white. Then, check the rendered texture for any white pixels. This method would require you create special shaders for rendering the texture. Edit: you can even go crazy with this method and have each object drawn and indexed by it's own "color", rather than simply white or black. This is how I USED to do mouse over detection (pre-unity).

avatar image ozturkcompany · Apr 09, 2015 at 05:25 PM 0
Share

I was hoping to re-create unity pro's feature of "Occlusion Culling". I can get accurate data with raycast but as i said it requires maximum 32400 rays which is pretty heavy i think. What i did was shooting a ray from the camera at al angles one by one and return the result of it, this works but slowly. Your method is crazy and i am just a beginner! I thought the collider's bounding box but that wouldn't be accurate so i passed that option. Still trying to get around on this. Thanks for the tips!

avatar image Wolfdog · Apr 09, 2015 at 05:38 PM 0
Share

I believe that occulision culling is in the free version of Unity 5 too.

avatar image ozturkcompany · Apr 09, 2015 at 06:00 PM 0
Share

Whaaaaaaaaaaaaaaaaaaaaaat? You serious?

avatar image Glurth · Apr 09, 2015 at 10:30 PM 0
Share

32400 rays

Woah! Even if you cast a ray to every single vertex of the target how do you get 32$$anonymous$$? (32$$anonymous$$ vertex mesh? I hope not.)

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KdRWaylander · Apr 10, 2015 at 07:05 AM

Hi,

You can use the built-in function which is renderer.isVisible : http://docs.unity3d.com/ScriptReference/Renderer-isVisible.html

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ozturkcompany · Apr 10, 2015 at 09:25 AM 0
Share

Hello, i will look for this and see if this was that i was looking for.

avatar image KdRWaylander · Apr 14, 2015 at 07:49 AM 0
Share

Is it what you were looking for ?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Internal collisions 1 Answer

Using a Single Collider to Detect Collisions with Multiple Colliders 3 Answers

OnTriggerEnter not being called with multiple colliders 1 Answer

Photon - Add force to other player 0 Answers

Attempt counter 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges