I was trying to create bots for my scene who walk around in scene randomly within the rectangular plane. So I was trying to generate bezier curve using multiple random points within the boundary and make each bot follow the one of the bezier curves
This is how it looks
but as you can see in the video many lines are crossing and overlapping each other and models are passing through each other and I wanna avoid that, so is there a way that I can make sure no line overlap another? Another approach comes in my mind is set up the ray casting for each bot and slow them down or reverse their movement when other bot is crossing or walking in opposite direction as them but again ray casting will hit a performance a lot and I might be using more bots in future
You wouldnât have to use full raycasting here - a 2D solution would be enough with each person represented by a point or a circle. When the points get close to another point, register a collision.
considering if I represent the model with circle, still iâll have to loop through all the circles for each circle on each frame, that still costly isnât it? Like If i have 10 models, ill have to check each of them against other remaining 9 models, right?
So for n=10 youâd need to do 45 checks each frame.
For 20, itâs 190 checks.
For 500 50, itâs 1225 checks.
It grows quickly - it wonât work for thousands of objects. But it looks like youâll just have 10 or twenty people walking around, in which case it should be fine.
A speed up would be to divide the room into a grid (or something fancier like a quadtree), track which grid area a point is in, then only check it against other points in the same area. But I wouldnât bother with that unless you have performance issues.
EDIT: actually that quadtree repo has a cool demo that probably does what you want - you could use this instead of making your own version:
Yeah, thats right, will have to check. Its weird I did not see any example of such case where people made a bots in scene, my first thought was to try some steering behavior or something lol, anyway will have to try this collision detection. Thanks for reply, that was really helpful.
Note that the grid has dimensions of n=6 columns and (n-1) rows. Clearly, the number of cells is n * (n-1).
Also note, that thereâs an equal number of skulls and thumbs-ups.
Since youâre only interested in the cells having the thumbs-up symbol, thatâs the lower-left half of the rectangle, hence n*(n-1)/2