What options are there for selectively controlling collisions?

Context: I’m geting dogs to pick up and carry around objects. Not quite decided how many we’ll allow in the scene at once, but i’d like to be able to handle several at least.

The system works mostly perfectly, but one major hitch is that a dog bumps into whatever its carrying and gets blocked by it.

The most obvious solution to me, would just make dogs not collide with things they’re carrying. But i WOULD still like carried objects to be able to collide with other dogs that aren’t the carrier.

I’m trying to think of ways to govern this, and the only method i have so far that seems workable is that when a dog picks up something, the dog gets put on a special layer seperate from the other dogs, and the object it’s holding gets put into another layer which doesn’t collide with things in the previously mentioned layer (but DOES collide with the layer where the rest of the dogs are)

This seems clumsy but i think it’d work for an isolated case. however, it isn’t really scaleable, since there’s a limited number of layers. that solution would require two layers for each pair of dog and held item.

i’m hoping there’s another solution, give me ideas please?

Does an item actually need a collider at all while being carried? You could just disable it.

EDIT: Ignore that, missed part of what you said… How about Ignore Collisions?


i want it to collide with other things though. For example i’d like a wide stick to get stuck in doorways and stop the dog going through. I’d like toys on a rope to be swung around with motion and hit other stuff

Updated at the same time, my bad.

now this is interesting, i like.

Is there any way to make it apply to whole hierarchies. how scaleable is it?

Could i make two entire ragdolls not collide with each other by excluding every individual pair? that seems like exponential complexity.

Why don’t you just make it a part of the dog? You can change an objects parent from code

All colliders of an object, including colliders of the children of that object, are called simultaneously when/if a collision occurs with any of them. You collide with one, you collide with all.

I imagine going through the transform list and recursively applying the exception to all children would generate some additional overhead, but that would pale in comparison to the effort that’s required from the engine when an actual collision occurs, I would think. Applying the exception of one hierarchy to another hierarchy would be just as simple in application, really, but the performance hit from the increased work that it would generate… you’ll have to test for yourself. I still don’t think it’s enough to really worry about in most situations though, since physics are complicated and processor-eatering-machines, and avoiding physics doesn’t feel like it could be worse.

Have one dog object and one world object like a dog bone

Then when the dog walks up to the bone and picks it up you BY CODE will change its parent to the dog. Then it will no longer collide with the dog as it moves with the dog. When the dog goes to place the bone somewhere just change the parent to something else. This should work if not let me know why

Because collisions with the dog’s collider will activate the OnCollision with the bone, and vice-versa- they’d be sharing colliders. That might be fine in this case, as I have no idea of the specifics of Nanako’s OnCollision functions for the dog objects or the bone objects, but in general practice it seems like it would be best to either disable the collider on the object being “picked up” (and then change parents, as you said, so the transforms are locked in that relative position), which Nanako doesn’t want to do in this case, or to add a specific collision exception between the bone’s colliders and the dog’s colliders.

There may be no reason at all why your answer won’t work here, though, you’re right.

well, the specific part of the object which is being grabbed, is parented to the dog’s mouth. but the rest of it is not, and remains free hanging but attached by joints (assuming objects with more than one rigidbody, not applicable in the stick scenario)

The problem with things blocking the holder is only present with multipart objects, such as our 7-part ragdoll teddybear. That’s what i need a solution for