CombineChildren and Physics

I am using the standard CombineChildren script to group a collection of spatially close objects sharing the same material. Great for performance. The only problem is that when they are grouped with this script the child objects can no longer react to physics independently.

What is the best way to modify the script so that the grouping/combine is disabled when a physics event like a collision is taking place so the proper independent object reaction can take place, then the CombineChildren can be reactivated when the independent objects go back to sleep (relative to physics anyway).

Does that question make sense? Seems like the CombineChildren optimization could be used more often if the objects it combined could still independently respond to physics.

Thanks,
Ricko

you’d have to pull the objects out to get individual interactions.

i haven’t looked at it but eric posted this package a while ago which might help:

http://forum.unity3d.com/viewtopic.php?t=4903

: )

Thanks. I’ve snagged the decombine script which was for Unity 1.6, to try out later, and unfortunately Eric’s web examples showing it in action are no longer available (I’m getting an Error 403: Forbidden).

Ricko

Oops, sorry…that site has very limited space, so apparently I removed those examples at one point. I’d sometime want to give that script an overhaul anyway, since I kind of quickly threw it together, so I’m sure it could be done much better.

A simpler approach in the meantime would be to make sure to use just an empty game object with the CombineChildren script on it for your object combining. When you want to decombine the objects, detach the children from the parent empty, and get rid of the empty, and turn the renderers for the children back on. So now they are the original separate objects again. To recombine, instantiate a new empty with the CombineChildren script on it and make the separate objects children of that empty. The next frame, they should be automatically combined again.

This isn’t ideal from a speed perspective, and I haven’t actually tested it, but if you don’t have that many objects and aren’t combining/decombining constantly, it should probably be fine.

–Eric