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 StewartB · Oct 24, 2013 at 07:52 AM · cameravisibleplanesfrustrum

Reduce size of plane frustrum in code

That probably didn't make sense. Let me explain. I'm using this code gem:

 public static bool IsVisibleFrom(this Renderer renderer, Camera camera)
 {
     Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera);
     return GeometryUtility.TestPlanesAABB(planes, renderer.bounds);
 }

which I found in the forums to determine whether something is in the camera view. Now, I want to make it so that it only detects things inside a slightly smaller frustrum, so things at the very edge of the screen aren't included. How can I reduce the size of this frustrum while maintaining the use of this code?

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 robertbu · Oct 25, 2013 at 10:17 PM 0
Share

As a hack, you could change the field of view of the camera just before the call and restore it after. Note if this is a 2D game there are simpler alternatives.

avatar image StewartB · Oct 25, 2013 at 10:20 PM 0
Share

No, it's 3D. I'll try your idea and get back to you.

avatar image bpears · Oct 25, 2013 at 10:31 PM 0
Share

Any reason you cant do it in the editor? what are you trying to accomplish here?

avatar image StewartB · Oct 25, 2013 at 10:33 PM 0
Share

I'm not trying to reduce the actual size of the camera's view (i.e. field of view), but rather the size of the frustrum that the code above uses, so that objects at the very edge of the screen are not contained in it.

avatar image bpears · Oct 25, 2013 at 10:36 PM 0
Share

Well.. if you really want a quick way, you could always place a box collider parented to the player, with on trigger checked, then code on collsion enter/exit stuff that detects other colliders within it. So, that would be smaller than frustrum planes, since it doesnt spread out of distance, just goes straight out, since, it can only be rectangular in shape.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by thef1chesser · Oct 24, 2013 at 08:20 AM

My attempt would be something like this

Bounds b = new Bounds(Vector3.Zero, Vector3(xsize, ysize, 1));
return GeometryUtility.TestPlanesAABB(planes, b);

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 StewartB · Oct 25, 2013 at 10:08 PM 0
Share

Would that be used in place of the above code?

avatar image thef1chesser · Oct 29, 2013 at 12:57 PM 0
Share

yes it would

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

16 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

Related Questions

How can I know if a gameObject is 'seen' by a particular camera? 11 Answers

Planar reflection is getting cut off when using camera with an oblique viewing frustrum 0 Answers

How to get a ParticleSystem to play when you can't see it's origin point. 0 Answers

Only show GameObject if at least 1 pixel is rendered 0 Answers

Renderer.isVisible always returning false 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