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 Rob 6 · Jul 12, 2011 at 05:04 PM · collisionrigidbodydetectionreturn

OnCollisionStay is not returning anything

I have a physics-controlled ball using a rigidbody, and I wish to use the normal of its contact point with the level. I intend the end result to be that when a forward force is applied to the ball, the y direction of the force is brought parallel to the surface that the ball is travelling on.

Most sources would suggest that OnCollisionStay is the way to go, but whatever I do, I can't get it to return any collisions whatsoever. The code I'm using follows Unity's example from the script reference - I can't do anything more with it until it actually works!

 void OnCollisionStay(Collision collisionInfo)
 {
     Debug.Log("I am colliding");
     foreach (ContactPoint contact in collisionInfo.contacts)
     {
         Debug.Log(contact.thisCollider.name + "hit" + contact.otherCollider.name);
         Debug.DrawRay(contact.point, contact.normal * 100, Color.white);
     }
 }

Naturally, neither the Debug.Logs or the DrawRay are getting called at this stage.

I've tried messing around with the ball's rigidbody collision detection and putting a kinematic rigidbody on the level, but nothing seems to make a difference.

Comment
Add comment · Show 11
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 zachypin · Jul 12, 2011 at 05:13 PM 1
Share

what are the two objects colliding? Because for example, two rigid-bodies colliding will not return any collision as occurring unless colliders are also attached.

avatar image Rob 6 · Jul 12, 2011 at 05:44 PM 0
Share

one is a floor object which has a mesh collider, the other is the controllable ball which has a sphere collider and a rigidbody.

avatar image zachypin · Jul 12, 2011 at 06:10 PM 0
Share

I suggest first doing something with OnCollisionEnter() just to test that the collision is being read initially

avatar image Rob 6 · Jul 12, 2011 at 06:12 PM 0
Share

Tried that, same result. It's not falling through the floor or anything, so it's definitely colliding... it just doesn't seem to want to admit it!

avatar image Rob 6 · Jul 12, 2011 at 07:51 PM 1
Share

So I made a new project to test it independently of my project, and it worked. Reopened my project, and now it works. I really REALLY hate it when Unity does that...

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Rob 6 · Jul 12, 2011 at 07:57 PM

It's not much of an answer, but all it took was a restart of Unity. Similar things have happened before, I just didn't remember! Tip of the day: If bulletproof code doesn't work, restart Unity and it will.

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 tylo · Jul 13, 2011 at 07:10 AM 0
Share

I have had the collision system do this to me on multiple occasions, and restarting has almost always helped.

avatar image Rob 6 · Jul 13, 2011 at 07:32 AM 0
Share

yeah, I guess it's just one of those things! It probably means PhysX has gone a bit haywire and needs a reset. Who knows?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

I want to pass objects through each other AND detect the collision 1 Answer

Collision-detection ALWAYS happens 1 Answer

Prevent rigidbody from colliding 1 Answer

Collision on character controller (fps player) 0 Answers

Rigidbody stops moving by code and then doesnt respond to collision 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