- Home /
OnTriggerEnter - race conditions?
Let's say I have 3 GameObjects - 2 of them (let's call them A and B) act like triggers and do something with the 3rd object (C) in their OnTriggerEnter method. I want make sure that if trigger A does something with object C, then object B can't do anything with object C anymore and vice versa.
The easiest way to achieve this would be to setup a boolean flag on the C object that's set to true in OnTriggerEnter method of A or B and check it each time I want to perform the operation on object C.
My question is - do I have to worry about race conditions and lock the boolean flag? Is it possible for OnTriggerEnter to be called from multiple threads at the same time or is it always sequential? I know that main game loop in Unity is single-threaded but I want to make sure if the same is true for physical calculations - like entering trigger in this case.
Your answer
Follow this Question
Related Questions
Problem: One Trigger activating a seperate Trigger it is not in contact with. 1 Answer
Sphere Collider set to Trigger acts as solid object 0 Answers
Is it possible to combine child trigger of a object to only trigger OnTriggerEnter once? 1 Answer
Ignore collisions with self but still trigger with self 2 Answers
Simple Triggers problem. 1 Answer