Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Rawas |
Hi
When my KinematicBody2D enters two Areas2D at the same time is it possible to decide which body_entered would be processed first ?
Without doing anything it’s totally random. Also Area2D has a member called priority
( The area’s priority. Higher priority areas are processed first. Default value: 0 ) but it doesn’t seem to work as I thought it will.
You may be able to use the Object
of the body_entered()
method. In the first Area2D
, have it set an accessible variable with the value true
when the Object
of the KinematicBody2D
sets off the signal. Have the second Area2D
check for the accessible variable in addition to looking for the Object
of the KinematicBody2D
.
Ertain | 2018-12-18 19:27
That’s what I’ve tried before posting the qestion. The problem is there is no such a thing like first and second Area, they are processed randomly. So if the body_entered() from “second” Area would be call first the flag still be false and it would be processed, and I dont want it .
Rawas | 2018-12-19 10:37
Ah, race conditions. Drat.
Ertain | 2018-12-19 12:52