Hello !
I’m making 3D shooter where players shoot at complicated mahines. MAchines doesn’t have HP bars instead they lose elements that were hit by the player.
I have a gamobject that has a rigidbody with non-kinematic phisics. It has about 600 sub-objects and each of them has one or more trigger colliders that are used only for raycast (hit zones). (Mostly spheres but some of them are Boxes) . It also has about 30-50 sphere colliders that repersents simplified phisical collissions with terrain.
If I use Rigidbobdy.set_mass operation on this object then it takes about 25ms in deep profile mode.
The strange thing is that when I delete all the triggers and leave the phisics colliders intact then Rigidbobdy.set_mass function time reduces about 200 times (!) to about 0.12 ms
Triggers do not take any part in phisics simulation. They are set to be Triggers and has different layer then the objects colliding with each other. They shoud not have anything to do with phisics they are just used to define hit zones for enemies shooting at the object. Yet they slows down Rigidbody.Set_Mass and set center of mass.
Maybe I can set them up somehow in order to exclude them from useless calculation ?
The only idea that I have right now is to remove triggers from rigidbody and create another object that follows rigidbody , doesn’t have phisics but has the triggers. And then communicate between those two object. But it seems like using unellegant hack
Regards
Zych