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 rogeriobrito · Jul 12, 2014 at 03:15 AM · raycastingfield of view

How can I tell the user can see an object, from any angle?

Hello all, Please check the image bellow. It is a big cube made of little colored cubes (gameObjetcs). The cubes for each color have its Tag. The user can rotate the big cube at will, viewing it from any angle. How can I tell the user could see the Red Cubes? If we rotate the big cube 180 degrees the red cubes would face the opposite direction and it will not be visible to user at that moment. But the user could see the red cubes if he rotates the big cube. As the game goes on, the little cubes are destroyed. I need to calculate when the user could not see the red cubes, no matter how he rotates the big cube. In this situation, the red cubes would be completely covered by other cubes. How do I do that? Calculate if the red cube could or could not be seen from any angle? Any help will be greatly appreciated Thanks alt text

cube.png (5.0 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by tanoshimi · Jul 12, 2014 at 06:20 AM

Try performing a raycast from the camera to the red cube (perhaps, for more accuracy you could perform several raycasts to each corner of the cube). If the red cube is the first gameobject that the ray hits then it is visible.

Note: Don't be misled by the renderer.isVisible property - although it sounds like this could be used to test the visibility of an object, it really only tests whether it is inside a camera frustrum (and therefore sent to the GPU to be rendered), not whether it is visible to a player.

Comment
Add comment · Show 3 · 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 rogeriobrito · Jul 12, 2014 at 01:28 PM 0
Share

Hi tanoshimi, I´ll try that and post the results here. Thank you

avatar image rogeriobrito · Jul 14, 2014 at 10:40 PM 0
Share

Hi tanoshimi, How can I calculate the raycast direction using the red cubes position? I have to do that to try a hit on the red cube, right? Thanks,

avatar image rogeriobrito · Jul 17, 2014 at 12:36 AM 0
Share

It works! To calculate the direcction for the raycast I have to do (target.position - origin.position). Thanks a lot.

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

2 People are following this question.

avatar image avatar image

Related Questions

How to get where my camera borders a plane 1 Answer

Obstacle avoidance 1 Answer

C# RayCast Fire Cooldown DeltaTime Help 1 Answer

Ultimate FPS Camera, Raycasting Troubles :( 0 Answers

Click Mouse anywhere for different actions 1 Answer


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