I am applying force to the objects, which can be connected at times. HOwever, in order to register that an objet is connected when passing through a gate, I have a larger invisible mesh to be detected first. (it’s a weight being towed by the playership , which will not always go first)
I don’t want the weights rigidbody to take force as though it’s the size of this larger detector mesh, but I am fully built around the rigidbody being on the parent. IS there a way to have some meshes be ignored by the rigidbody?
edit: I’m talking about the center of mass, I want the center of mass to be only where the “visible” meshes are.
edit:: yes it is not outlined as clearly as I would like, because it does not say specifically in these words : “trigger colliders and meshes without colliders that are children of parent rigidbodies do not affect the center of mass, the center of mass is only determined by those colliders that are not triggers”… I mean it does say that, but it’s rare in the search and is only sort of said as “the center of mass is determined by all colliders”.
With a script you can set where the center of mass is, for any Rigidbody. You don’t have to rely on the default centroid of colliders, which is the default calculation done when you never set the center of mass.
You can also make your larger “detector” collider as a trigger so it passes through most objects, and it will not affect center of mass. Triggers can detect other triggers as they overlap.
The rest of the question is not clear to me. A Rigidbody needs to be at the root/top of the hierarchy of things that behave in unison, so all its colliders are necessarily on the object or on child objects. If you need two sets of things to move in unison, you can create a Joint that keeps them inter-connected in various ways.
yes so the desire was to select which colliders interacted with the center of mass, so as not to set it myself, but instead to have it naturally function with the visible “weight” that would be fixed jointed to the bottom of my player ship. But, my issue was not that it was counting the trigger colliders to change the center of mass, my issue was that I did not understand that trigger colliders were not counted, as although I did find this afterwards, it took me a while to be confident I understood correctly, as the wording in the documentation is a tad bit indirect. I usually like to keep searching until I find very direct explanations, but in this case they are few on the top search list.
The end result is I am creating a rigidbody in script on the prefab parent, and the interaction meshes that are not part of the “object” itself are either no having colliders at all (to be visible transparent fields, or meshes with a center to have a difference from the playership, as in lining up for docking) or have trigger colliders (as in a pre-trigger if the weight is connected, so that when the ship trigger hits the field that needs to know if a weight is connected, the weight can actually trigger that field first with the larger trigger bubble).
My uncertainty was mostly in whether triggers and colliderless meshes would affect the center of mass. And then as a newb I struggled to put that into words, since I didn’t know them all at first.
thank you!!
edit::: just for comment, while I was trying to find how the physics worked, I wondered for a while if I could have the rigidbody ignore layers to result in this as well?? So, if the rigidbody ingnores a layer which I create, and add to all of these trigger meshes and visuals meshes, would this prevent the physics engine from adding them to the center of mass??? I understand the rigidbody would ignore layers for collisions, but for center of mass??? I didn’t test it because i didn’t find the proper scripting example before settling on the triggers did it for me.
I do however potentially plan to explore having inflatable objects, where one part is very heavy and a very large part of the object is virtually weightless, but does collide with everything around it. So I was wondering about the ingore layers for rigidbody, whether I could use that to affect which meshes are counted in the center of mass.
The built-in center of mass calculation is pretty hardwired. All non-trigger colliders have their own center, and the Rigidbody just splits the mass evenly throughout each of them, and averages. That’s all. No layer sensitive mass, etc. This is why they let you set it yourself through whatever calculation means you want.
As for collisions, they’re chosen by the “collision matrix” in your Project Settings > Physics section. But again, code can override those defaults, and you can say “these two colliders will never collide, even if they’re on colliding layers in the matrix.” This done automatically for all the colliders inside a Rigidbody’s children, but you can also call it yourself for special cases with Physics.IgnoreCollision().
For the inflatable case, I suggest you look into the methods that many water buoyancy routines work. They keep track of a number of smaller points that you distribute through the volume, and each one of those is tracked for the force of gravity independently with AddForceAtPosition() according to some criteria, instead of a single AddForce() for gravity as a whole at the center of mass.