During animation from keyframe A to keyframe B, I would like to move many objects from their starting positions to the location of vertices in an object. Example: Start: enter image description here End:enter image description here Is there a way to assign them automatically, getting the shortest path for all and avoiding collisions / keeping a minimum distance? I would need to do this for dozens or hundreds of similar objects and several times, so manual is not an option.

  • 2
    $\begingroup$ Getting the shortest path while avoiding collisions sounds like a very hard math problem to solve 🤔 Of course if you don't want to be very rigorous about that requirement, you could use Python to iterate over all objects and all vertices, use machine learning to get an optimal solution which you would describe as let's say the set of paths resulting in the shortest animation (so minimizing the longest of all paths). All in all, sounds off-topic and more related to the fields I printed bold. $\endgroup$ Mar 31 '21 at 14:17
  • $\begingroup$ Oh and in the non-rigourous approach the balls would just wait or move slower if they would otherwise collide. $\endgroup$ Mar 31 '21 at 14:25
  • $\begingroup$ This definitely seems like a fairly involved Python task. It's a pretty particular goal so there are unlikely to be any existing tools to just do it for you. $\endgroup$
    – PGmath
    Mar 31 '21 at 14:35
  • $\begingroup$ I did a bit more trials and research now. I feel a good framework to get the objects from A to vertices of B are animation nodes and I got that working. But the assignment is not optimized for shortest paths. The mathematical theory behind the optimal assignment seems to be the Hungarian algorithm. geeksforgeeks.org/…, which is also implemented in python docs.scipy.org/doc/scipy-0.18.1/reference/generated/… Since I am neither a Python nor Blender pro, it will take me some time.. $\endgroup$
    – ChrisM
    Apr 3 '21 at 4:21
  • $\begingroup$ If you represent each salesperson by a ball, and each city by a vertex, yes it works - if you drop the collision requirement. Keep in mind that sending a salesperson to a given city doesn't change the fares of other salespeople to other cities, whereas in your case it does, and moreover that change depends who was sent (so not only a distance to a vertex is specific for a given ball, but also it's path and therefore taken space). $\endgroup$ Apr 3 '21 at 7:51

You may be able to use particle systems to do this. The Harmonic force-field can set up a one-to one correspondence between particles in source and target systems. With damping set to 1, source particles stop at their target-partners locations.

  • On the target, set up a particle system with no physics, [vertex-count] particles emitted from vertices, all at frame 1.
  • In 'Force Field Settings', set the target system to generate a Harmonic field, with quite a high strength, and Damping of 1:

enter image description here

  • Set up a source particle system, set the emission as for the target, this time from the source object, and in its 'Field Weights' set it to respond to the Harmonic field of the target.

So far, so good. The source system will be attracted to, and land on the target system (which you will be hide, in any render)

The remaining question is how to avoid collisions between the source particles on their journey to the target..

  • Here, in the 'Force Field Settings' of the source system, I've given the particles a 'Charge'. This does, at least, seem to cause enough repulsion between particles to avoid interpenetration:

enter image description here

Options might include giving the source system 'Boid' rather than 'Newtonian' Physics, with an 'Avoid' rule, and plenty of 'Personal Space'. If the worst comes to the worst, you could have a third particle system with 'Keyed' physics, which would let you mix-and-match between other particle systems, picking the parts of their behaviours which work for you.

Have a play, anyway, it might be a starting-point.

  • $\begingroup$ Thanks, that looks neat. I am not familiar with particles, need to see if they also do the trick for what I need. Will report back later. $\endgroup$
    – ChrisM
    Apr 1 '21 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.