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
2
Question by Christian 7 · Mar 11, 2011 at 08:53 PM · collisioncollidermultiplecollisions

Why does OnCollisionStay returns multiple contact points in such a strange way?

Hi there, updated this Question, because of something I noticed and to clarify some more:

I've got a rigidbody with a spherecollider and need a way to keep track of all the points it is currently in contact with. I thought OnCollisionStay would be the way to do this, but somehow it gives unexpected results.

My test cases are the following: The SphereCollider is sitting on a stairway, in case A composed of BoxColliders, in case B a single mesh collider/imported 3dmodel

CASE A

CASE B

Than I'm printing the contact.points with this script:

function OnCollisionStay (collision : Collision) { grounded=true; print(collision.contacts.Length); for (var contact : ContactPoint in collision.contacts) { print(contact.otherCollider + " " + contact.point); } collisions = collision;

 }

As you already may have noticed in the pictures the console output is very, very strange:

In Case A it says it has 2 contact.points, but then prints 2 times the coordinates of the first contact and than 2 times the coordinates of the second, instead of printing both coordinates at once.

CASE B is even worse it says it has 2 to 8 contacts and about half of the printed coordinates belongs to the first and half to the second contact point.

I considered that this might have to do with the number of vertices of the stairway mesh compared to the two box colliders, but I dont see why this should be the way oncollisionstay is supposed to work. Maybe I'm wrong but shouldn't be the output more like this:

Number of Contacts

Coordinate 1.Contact

Coordinate 2.Contact

...

Number of Contacts

Coordinate 1.Contact

Coordinate 2.Contact

...

If anybody knows the reason for this, or has any suggestions for a work arround, so that I can have an output like shown above, I would be very glad.

I hope I described the problem well enough, otherwise feel free to ask and I will clarify. As alway any help is appreciated. Thanks!

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 Statement · Mar 12, 2011 at 05:51 PM 0
Share

Could you also print out the normal of the contact?

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

No one has followed this question yet.

Related Questions

How to do collision of external objects on script? 1 Answer

How to call only ONE OnCollisionEnter, on one of two objects 1 Answer

Why there is no Collider.IsTouching(...) ? 2 Answers

Quad mesh collider detects side collisions when it should not 0 Answers

Detecting multiple gameobjects 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