Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Naphier · Jan 20, 2016 at 09:07 AM · cameraboundsorthographic camera

CalculateFrustunPlanes / TestPlanesAABB returns unexpected results

I'm trying to figure out how to bind a camera to a viewable area.

The camera is orthographic and rotated to (30,45,0) for an isometric view.

The camera is a child of an unscaled gameobject with no rotation (this parent is used to control position easily).

When I generate planes using the manual's example of CalculateFrustumPlanes, the planes are all over the place.

I need the functionality to work with different orthographic sizes as that will be used to zoom the camera.

If I use the below code to check if a collider is within the frustum I get erroneous results (see image).

     bool doOnce = true;
     public Collider[] toDetect;
     private Plane[] planes;
     string detected = "";
     void HandlePanBounds()
     {   
         if (doOnce)
         {
             doOnce = false;
             /*
             int i = 0;
             while (i < planes.Length)
             {
                 GameObject p = GameObject.CreatePrimitive(PrimitiveType.Plane);
                 p.name = "Plane " + i.ToString();
                 p.transform.position = -planes[i].normal * planes[i].distance;
                 p.transform.rotation = Quaternion.FromToRotation(Vector3.up, planes[i].normal);
                 i++;
             }
             */
         }
         Plane[] planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);
         detected = "nothing";
         for (int i = 0; i < toDetect.Length; i++)
         {
             if (GeometryUtility.TestPlanesAABB(planes, toDetect[i].bounds))
             {
                 detected = toDetect[i].gameObject.name;
             }
         }
     }
 
 
     void OnGUI()
     {
         GUI.Box(new Rect(0, 0, 100, 100), "Detected: " + detected);
     }

HandlePanBounds() is called in Update().

All help is appreciated. I've Googled this and tried a variety of answers for the past 2+ hours and they aren't getting me anywhere.

Comment
Add comment · Show 1
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 Naphier · Jan 20, 2016 at 08:25 PM 0
Share

Well, I've found out that the issue may lie in how I'm using TestPlanesAABB. I'm trying to detect a somewhat large collider (Size is (100,1,2100). If I make that collider less than 100 units the detection seems O$$anonymous$$. Not ideal though and I'm not 100% sure this is the issue. I also noticed an error in my visual representation of the planes. They now show in the correct locations, but the TestPlanesAABB issue still persists. I will likely be looking in to just doing a raycast from the camera's bounds when I can figure that out. Tips on that are welcome.

0 Replies

· Add your reply
  • Sort: 

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

38 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 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

How do you zoom with an orthographic camera? 1 Answer

Aquarium like camera 1 Answer

Implementing Camera bounds proportionally to its ortographic size 0 Answers

How to make WorldToScreenPoint work with an orthographic camera? 0 Answers

Best Setting Size Orthographic Camera? 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