Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 irn-art · Aug 08, 2015 at 02:47 PM · physics2doverlap

Physics2D.OverlapArea not working at certain positions

Hi, I have a problem with Physics2D.OverlapArea.

I have a single game object with BoxCollider2D. I use Physics2D.OverlapArea to check whether the game object is in certain area. When I move the game object further from the world origin (e.g. y = 19) and check the area that my game object occupies, Physics2D.OverlapArea does not return a hit. This occurs only at some positions. The further I move the game object from the world origin, the more often this problem occurs.

My game object is at position -5, 19, 0. The size of its BoxCollider2D is 0.5, 1. It has this script attached to it:

 void Update () {
         var bounds = GetComponent<BoxCollider2D>().bounds;
         var center = bounds.center;
         center.y += 0.01f; //WITH SOME OFFSETS, IT WORKS; WITH OTHERS IT DOES NOT
         bounds.center = center;
         
         var result = Physics2D.OverlapArea(bounds.min, bounds.max);
         Debug.Log(result);
     }

the 'result' in the example is null. Thanks!

UPDATE:

It seems like the problem occurs only if the game object`s left edge has the same x position as the tested area`s left edge and the game object`s right edge has the same x position as the tested area`s right edge. The problem still occurs only at certain positions with y > 12+.

Can anyone help please? It really makes me frustrated :(

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

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

2 People are following this question.

avatar image avatar image

Related Questions

[2D] How to get gameobjects within a tilted rectangle area 0 Answers

Steering Separation Behavior: objects move endlessly from center 0 Answers

OverlapCircle or OverlapArea best performance? 1 Answer

LayerMask help 2 Answers

Checking for Colliders with Physics2D.OverlapBoxAll Won't Work? 0 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