Hello everyone.
How to organize the movement of a group of units from point A to point B without colliding with each other?
In this case, pathfinding and separate objects are used when colliding with each other.
As a result, the tank’s body is repelled and the point moves along an incomprehensible trajectory.
I’ll give you an example of how it looks at the moment.
https://drive.google.com/file/d/1V6CpEwTM1tCOMfM69cLs2TyUfcw3Zuks/view?usp=drive_link
Maybe try adding another action on collision that re-pathfinds? It might get laggy if there are too many collisions though, idk
I’ve played with the concept in the past with mixed results. Here are some ideas.
You could move 1 object and create the other troop members using the animated shadow clones extension. The copies follow the original. It’s a bit like a snake. Once the destination is reached the clone function can be stopped. It might need more to unlink the objects from the cloning extension. IDK.
Use a scene timer and add a delay to the movement of members of the troop. Every X seconds move a member with the pathfinder. You could either use an ID or pick the member closest to the destination.
When members collide change the speed or stop one of the members. I’m not sure how you would decide which one to slow down. I guess either using an ID or distance from the destination.
I’ve never tried to create formations. That could work. Only move 1 member and then place other members around it based on angle and distance. Add a little randomness to the distance or angle to make it more natural looking. Alternativly, instead of a fixed distance/angle, the points around the leader could be used as pathfinder destinations.
I liked your idea, the movement of objects one after another. I can’t implement this. I added an identifier to each object. How can I make it so that the selected object with the largest identifier moves to the cursor, and all the other selected ones move after it?
try using boids movement + the other pathfinding (i forgor the name)
You could use a timer. If you’re highlighting the objects that you want to move then I guess you could create an array from the selected objects and then use a timer and the array tools extension to sort and then remove the last index. Are you using the RTS extension for the selecting?
I wanted to test my idea. I used the RTS extension and array tools. I had a Troop object and shape painter with the fill opacity set to 100. The troop had an outline effect. I used a mode variable (default value of Select) to set the mode and CurrentID to hold the last ID in the array named List.
The code is minimal. It needs more checks and things. I assigned a random ID just because I didn’t feel like numbering them.
I don’t love this version. Unless the delay is large, they don’t move orderly. It’s a bit of a mess. I think it would work better if they were moved in order of distance to destination using the nearest first. That would be easier. It wouldn’t require an array. I might mess with that version later. I love playing around with concepts.
I wish this was cleaner but it shows the concept of moving based on distance . Because the RTS condition that checks if an object is selected only returns true/false but doesn’t pick the objects, I added a selected boolean to the troop. This allows the nearest object of the selected to be picked and then removed from the list by setting selected to false.
I noticed an issue with my original concept. It used the cursor position as the destination but since there’s a delay, the destination could change if the cursor was moved. To get around that, I added events to set X and Y to the cursor position.
I do not use the RTS extension.
In order to select an object, I use the logical variable “VarPlSel” and the effect “outline” in the object properties.
After double-clicking the mouse, a “tilemap” object is created, if it swings the “tank” object, then its logical variable changes to true and the “outline” effect is applied, after double-clicking the mouse again, a marker is created and all tanks with a logical variable equal to true move to the marker.
OK. The 2nd version uses a selected variable although, it clears it as the objects move. I think the concepts are there.