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 spunktrumpet · Sep 23, 2014 at 02:04 PM · collisionrigidbody

Collision detection only half working.

I'm having a little bit of trouble with my collision detection. I have a player cylinder which rotates around a centre point using 2 keys. From that centre point, cylinders are instantiated and scaled up, so heading towards the player. I need to get a collision detection working to detect if the two objects have entered and exited one another however I'm having some trouble. If I set my player as a trigger and use onenter/onexit it only works half the time and the player has to be moving at the time of the collision for it to be detected, if it's stationary no collision is detected, also onexit is never detected. The player has rigid body, sphere collider which is a trigger and is detecting the collisions. The other objects have mesh colliders. Any ideas?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Raggers · Sep 23, 2014 at 03:09 PM

Don't know if this fixes your problem: Try adding a ridgidbody to your cylinders.

Some tips on physics:

Boxcolliders (or meshcolliders) are meant to be static objects. If they are not moving they are put to sleep to save CPU resources and only a other moving object - like your player - will interact with them but only if it is moving, if not your players collider is put to sleep too.

Ridgidbodies are the dynamic version of a collider. Moving a collider uses more resources then moving a Ridgidbody.

Setting the position of a ridgidbody is not seen as moving it, to move a Ridgidbody use the MovePosition() function.

And if you Ridgidbody is kinetic you need to use the FixedUpdate() to interact with it. This is because the physics layer is not in sync with your Update() function. Where as FixedUpdate() will be called before every physics update.

To sum it all up: Boxcolliders are static, Ridgidbodies are dynamic, always use FixedUpdate() for physics interaction and if two objects are not moving they can never hit so the physics layer ignores them.

(Please correct me if I am wrong, still learning the ins-and-outs of unity)

Comment
Add comment · 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

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

26 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

Related Questions

how to make an Explosive rigidbody trigger by another collision box 0 Answers

OnCollisionEnter not called on Unity4.3 for 2D. 1 Answer

rigidbody collision and forces 0 Answers

Why is this rigidbody not activating the trigger? 0 Answers

Turning an object into a RigidBody and applying a force on it... 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