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 /
  • Help Room /
avatar image
1
Question by CosgunHalil · Apr 03, 2017 at 11:12 AM · collision2dcontacts

Unity5.6 Collision2D contact points array problem

When I updated my Unity version 5.5 to 5.6, an error occured about the Collision2D.contacts array. When I try to access the contacts array, I can not get contact point info now.

 void OnCollisionExit2D(Collision2D col)
 {
     if (col.gameObject.CompareTag("Ground")) 
     {
             if ((_transform.position.y - col.contacts[0].point.y) > colliderHeight / 2 + .15f) 
             {
                 Debug.Log ("Contact count = " + col.contacts.Length);
                 _onGround = false;
                 ParticleController.PlayDustEffect ();
             }
 
         }
     }

IndexOutOfRangeException: Array index is out of range. Player.OnCollisionExit2D (UnityEngine.Collision2D col) (at Assets/Scripts/CharacterController/Player.cs:759)

How can I fix the error?

Thanks for your time.

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 Andrii · Apr 04, 2017 at 08:01 AM 1
Share

Having same exact problem. Looks like they've changed A LOT about how colliders are working in 5.6. Retrieving contacts with GetContacts() doesn't work too.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hexagonius · Apr 04, 2017 at 08:24 PM

you won't get contacts on exit. I ran into the same problem. I even received answer from unity support. I don't know if this ever worked, but it didn't with unity 5.5. thinking of it, it doesn't make sense to work too. to detect if two colliders no longer overlap, they just don't anymore. it would be a backtrack for contacts, like inverse continuous dynamic collision detection.

Comment
Add comment · Show 1 · 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 Andrii · Apr 04, 2017 at 08:28 PM 0
Share

It was definitely working for me in 5.5. And it totally makes sense to detect which colliders triggered on exit event and where the exit happened.

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

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

The collider doesn't seem to move with the object, using AddForce to move. 0 Answers

Problem with hit detection and corountines 1 Answer

Can't make the player attack an enemy 0 Answers

Pre-solve Collision 0 Answers

Delete prefab clone when collided with the player, Unity 2D 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