#Pathfinding Hallway-Dance race conditions problem

1 messages · Page 1 of 1 (latest)

round flower
#

trying to solve this is harder than I thought

My units avoid eachother in the same direction and get stuck occelating.

I THOUGHT it would be as simple as: one unit makes a decision, the other makes the opposite decision, and 'race conditions' wouldn't matter because all that matters is ONE of them decides first.

But apparently the way unity works, they both decide in unison, in any order, before writing the answer to their own decisions to themselves. So neither is 'first' and neither can see who went 'first', so they both go the same direction, both see the other is going that direction, both choose to go the other direction because neither can see that the other updated its vector because the writing of the decision to change vector happens 'later' as in race conditions 'later' and not a 'measurable later' as in like next frame.

This is the first time ive faced race conditions I think. The way I thought it would work would work if instead of them making their own decisions, some kind of AI coordinator iterates through every unit in an arbitrary order, and has them explicitly make the decision, write the decision, one after the other, every frame for every unit. But that sounds maybe slow and bad?

Is that how you solve this situation or is there a smarter sollution?

round flower
#

this is what im trying to achieve

#

but I can't find logic that produces this

leaden bough
#

If this is all through raycasting I would probably have some buffer of locations/colliders (and maybe a directional vector if the object is traveling?) where an object may end up next physics frame which would eliminate the race condition. May be quite expensive if we're talking a bunch of units though.

leaden bough
round flower
#

I did some more work on it

#

its a lot better now, but something about this just isn't right
but I can't figure out what, I cant put my finger on it, when I look at it my body is screaming at me that its wrong, but won't say why
its like im looking at a corpse; uncanny valley is extremely enraged but I just cannot figure out why or what needs to change
they arent getting jammed up, the pathfinding avoidance 'works', but it.. works.. wrong? its wrong, yet its getting the job done, but its screaming at me its wrong
but I dont know why, all I know is that I hate it for some reason, and I cannot figure out why or how to fix it

#

like the hallway dance never happens