r/howdidtheycodeit • u/FakeTails • Feb 27 '21
Question How did they code the group movement in Pikmin?
In Pikmin the controllable Pikmin when called follow the leader, group up, can be pushed, dismissed, and the group continues to keep its general form properly and follow commands. How does the system handle keeping the Pikmin from trying to navigate through one another, and continue forming properly when one is removed and so on?
47
Upvotes
22
u/ThatWeirdKid-02 Feb 27 '21
Mix and Jam made a video recreating pikmin's mechanics, might be of interest
14
u/TheSkiGeek Feb 27 '21
Most likely variations on https://en.wikipedia.org/wiki/Flocking_(behavior)
This page has some interactive widgets that let you play around with it, plus code:
http://harry.me/blog/2011/02/17/neat-algorithms-flocking/
6
u/RyanMakesGames Feb 27 '21
This video by Scruffy has some insights into how the Pikmin animate on the title screen and may provide some insight into the problem.
1
u/Niels___ Feb 27 '21
Maybe look at dijkstra or flood fill algorithm. Basicly, calculate a movement cost from a grid tile, towards a target. By calculating every "tile" cost you can place pikmin everywhere and they still move to a desired target. Instead of only being able to use the calculated shortest path (like you get by using A* pathfinding).