How does Unity handle same-script calculations that occur sumultaneously?

Ex: An enemy is hit with two projectiles within the same frame, and both will have to calculate and apply damage.

Does it (kind of) multi-thread or queue the two calculations?
Does it ignore one of them?
I obviously want both calculations to occur, so do I have to write a bit of extra code that will allow for this at all?

Suggestions for how to do this (or work-arounds) would be helpful, thanks. [^_^]-b

OnCollisionEnter / OnTriggerEnter would be called twice. No special actions would be required by you.

There’s not really any such thing as “occur simultaneously”; they are run sequentially. Unity uses a single thread for scripts.

–Eric

Thanks for answering, both of you.

So the script would simply be ‘played’ twice, but in what way? Would one script finish doing its business before the other one starts?

Have a look at Unity - Manual: Order of execution for event functions. It show exactly what happens when.

I was looking for something like that! Thanks! :slight_smile: