- Home /
I need non-convex colliders to work with non-kinematic rigidbody
Hello.
My goal is to have an object (eg a sphere) that can have a force applied to (therefore the rigidbody can't be kinematic). This sphere needs to contain a lot of little objects (like a lotto rolling sphere).
This is what i've done so far : i created the parent object (the sphere) with a semi-transparent material, non-kinematic rigidbody and a convex sphere collider. This object have a children, called "container". In blender, i have inverted the sphere normals so i have a non-convex sphere container. The container have a this new created sphere as a mesh collider. The engine forced me to add a kinematic rigidbody.
This way, i was able to instanciate objects in the container and they seem stay in it. In addition, i can move the parent sphere and it can roll on the ground, all the little objects have gravitation applied to.
The problem is that when the sphere move too fast, all theses objects passe through the container. I think the reason is that the container have no forces applied to, the position is just recalculated on the basis of the parent (the sphere). That could explain why changing collision detection mode have no effect.
There would also be the possibility to force, by a script, to force all the objects to stay in the radius of the sphere. Unfortunatly, in the future, the container object will not be a sphere so this workaround can not work.
Help would be greatly appreciated, thanks in advance.
I don't get this:
I think the reason is that the container have no forces applied to, the position is just recalculated on the basis of the parent (the sphere)
are you talking about 3 object types? container, sphere and your little objects?
sorry, i was talking about the container.
I think there are no forces calculated with the container, because it's what kinematic rigidbodies do.
It's like moving object in the editor, the new position is set without calculating collisions. But when, in the editor, you move objects slowly, it gives the impression that forces and collisions are calculated because there is no gap between two positions. I think it's what is happening here.
two things to consider: move the container in FixedUpdate. $$anonymous$$ove it with $$anonymous$$ovePosition.
Answer by FuzzyLogic · Mar 20, 2018 at 08:08 PM
What is happening is that your objects are moving so fast that the collision tests skip right past the wall of the sphere. Making the wall of the sphere thicker will help with the problem but you will still have the same issue at higher speeds.
.
What you want is to set the RigidBody Collision Detection mode to ContinuousDynamic for your sphere and the balls.
.
Discrete mode only tests the objects at the position where the object arrives at each frame, whereas ContinuousDynamic does what is called a 'sweep' test, testing all the positions between where the object was and where the object has moved to since the last frame.
.
Sweep testing (ContinuousDynamic) is much slower than Discrete so use it sparingly but it is much more accurate.
The problem is that when the sphere move too fast, all theses objects passe through the container. I think the reason is that the container have no forces applied to, the position is just recalculated on the basis of the parent (the sphere). That could explain why changing collision detection mode have no effect.
I already tryed changing detection mode. See my comment http://answers.unity.com/comments/1482983/view.html I explained what I think is going on.
Your answer
Follow this Question
Related Questions
Compute mesh inertia tensor failed - NOT the usual problem 0 Answers
Why do I get OnTriggerExit upon collision when a rigidbody is kinematic? (example) 3 Answers
Is it necessary to attach a rigidbody/colliders to child objects? 1 Answer
Should rigidbodies be destroyed as they fall out of stage? 1 Answer
Player Pushes Enemies. (That's bad) -Still Unanswered- 1 Answer