Hi I have a kind of funny error. I made an enemy soldier for a project and i have different colliders (triggers) in his arms, torso, head, etc. so he can receive different amounts of damage depending on where i shoot him (these hitboxes detect the damage and send a message to the soldier with the damage changed according to the location of the hit). The problem is if i shoot him with a shotgun at close distance, he could receive damage in two or more points at the same time so he "dies twice". This shouldn't be a problem except for the fact that two ragdolls-corpses are instantiated at the same time (lol death mitosis). Does anyone have any idea to avoid this? how can i make sure that a script doesn't get executed twice at the same time? Regards.
Sure add a new bool to the class called _alreadyDestoryed, init it to false, then in where you instantiate a new corpse check for the destroyed bool. Code (csharp): if(_destroyMessageRecived !_alreadyDestoryed) { _alreadyDestoryed = true; Instantiate(theCorpse) }