Children of a hingejoint not colliding with parent's mesh when connectedBody is assigned
Imported an FBX mesh of a rover (something like a primitive Mars rover), with a robotic arm.
I'm working on the first HingeJoint, got it working to satisfaction operating the first section of the arm.
If I use the connectedBody property to connect the hinge to the bot's "parent" Rigidbody, the arm does not collide with the mesh of the bot (it passes right through it).
When I remove the connectedBody, it collides as expected (and operates while the bot is not moved), but of course when the bot moves, the arm basically falls off (and behaves oddly).
Mye objective is to enable the collision of the arm's mesh with the bot's mesh, but it seems that such collisions are disabled between the children of the hinge and the connected body.
I was considering manual configuration of the connectedAnchor, but I'm not exactly sure how to go about it.
Should I write script in the parent to the hinge so that fixed update positions the hinge's anchor or connected anchor?
Is there a way to re-enable "self collision" of this bot?
Many thanks.
Answer by Bunny83 · Jul 26, 2018 at 09:14 AM
Yes, by default the collision between connected bodies are disabled because when their colliders overlap they would get seperation forces applied. However if you ensure proper setup so the two connected bodies can rotated without overlap except at extremes you can simply enable collisions with the enableCollision property. You can simply enable them in the inspector as well.
Note that using limits for each hinge joint usually gives better results
Limits were not an option because this is the simulation of a real robot, where a robotic arm will collide with the bot's body and the arm collides with itself. The joints of the real robot can, in theory, rotate continuously through 360 degrees, and the wiring is usually the only limit when the arm isn't attached to the robot, though sometimes a flange or bracket from one arm segment will hit the 'parent' arm segment at rotation extremes.
There is no choice by to enable collisions so the arm stops when it hits the bot's own structure, and PhysX as exposed in Unity just doesn't support all that is required. The newest PhysX offers articulated joints with some support for this, but that will have to wait for a future version of Unity to expose, if ever.
This kind of simulation is exampled in AutoDesk's Inventor, but that's not a game simulation, it is an engineering simulation.
Your answer
Follow this Question
Related Questions
Rotate a hinge joint on its own 0 Answers
Code is acting different depending on call 2 Answers
Collision is not working with some Collider2d 1 Answer
Can't make the player attack an enemy 0 Answers
How to show an object when collided with 0 Answers