• 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 sweatyrat · Oct 19, 2014 at 02:12 AM · physicsraycastcolliderchildray

why are child colliders sometimes ignored?

i have noticed in a number of my projects that when i instantiate an object with a rigidbody and then give it a c$$anonymous$$ld with a collider the physics engine will sometimes ignore that collider even tho it is active. if i toggle the collider off and then on in the editor it magically starts working or if i cast a ray onto it in script it starts working. so what is causing the physics engine to ignore the collider and is there a better work around than casting rays on all of my instantiated objects to force unity to recognize that it exists?

EDIT: THIS BUG HAS BEEN FIXED IN UNITY 5+ AND IS NO LONGER A PROBLEM.

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 ibrahimddeveloper · Jan 27, 2021 at 01:04 PM 0
Share

No it's not been fixed, it's as frustrating as ever!

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Owen-Reynolds · Oct 19, 2014 at 03:26 AM

I'm pretty sure there's a few situations where changing an object in code will confuse physics. Seems like you have to "kick" it to get it to recalc values. The simplest solution is to do t$$anonymous$$ngs the "Unity way" if you can -- like Instantiate parent+c$$anonymous$$ld all at once (if you have 4 configurations of parents/kids, make a prefab for each.)

One t$$anonymous$$ng I t$$anonymous$$nk I've had success with is what you describe doing by hand. In code, set the object inactive then active (or kinematic/non?)

Comment
Add comment · Show 4 · 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 sweatyrat · Oct 27, 2014 at 05:05 PM 0
Share

unfortunately i can not use prefabs for my project. i am creating a voxel based game where the player creates the objects block by block. the problem is sometimes the blocks they add are ignored by physics and sometimes they aren't. and interestingly when i go thru and toggle them on and off it fixes the ones that are broken but then breaks the ones that were working.

toggling the kinematic property dose nothing. toggling active on the parent(rigidbody) object works but then all connected joints go nuts.

toggling the collision detection mode works but if i go from discrete to continuous and then back to discrete collisions work when the object is moving but as soon as you stop they fall thru each other. going continuous-discrete-continuous works great but then im stuck using continuous mode which i dont need and it causes lag

avatar image Owen-Reynolds · Oct 28, 2014 at 05:19 PM 0
Share

Joints have their own set of issues. When you make one, I think, the current position is always taken to be "at rest." In other words, there's no way to properly add a hinge to an open door (well, maybe by playing with the limits: -45/+45 becomes -90/0. Maybe.)

So I wonder if the toggle active/inactive is resetting joint "at rests."

I've never seen a decent guide to Unity joints, esp. dynamic joints.

avatar image titulus · Nov 18, 2014 at 06:04 PM 0
Share

If you have problems with adding a joint at runtime, try adding a joint component in FixedUpdate frame and use next and/or previous FixedUpdate frame to position the gameobjects you want add the joint.

This is because, when you add a joint component on a gameobject the joint component uses the current position of the gameobject/gameobjects for initialization.

avatar image Owen-Reynolds · Nov 19, 2014 at 03:38 PM 0
Share

titulus: Gah!! Is this the "takes 1 physics step to see new location" issue? So if, in one update, you move an object then add a joint, it will connect based on the old position?

Disclaimer: I have never experienced anything like this.

avatar image
0

Answer by sweatyrat · Jan 27, 2015 at 07:15 PM

After a long time of frustration and experimentation i have had some success by simply setting the rigidbody's transform equal to null after all the colliders have been attached. that seems to be the only way to compleatly reset the collision calculations.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

29 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

Related Questions

Don't allow raycasts to go through colliders? 3 Answers

Someone can help with Ray/Collide? 1 Answer

2D Collision not working! (child sprites colliders) 1 Answer

Returning list of Triangles, Vertices or Points by raycasting through a mesh (iPhone) 1 Answer

Physics.Raycast not checking layermask properly? 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