-
Notifications
You must be signed in to change notification settings - Fork 1
Unit and projectile motion
Beware, you enter into a dark place full of strange creatures...
The hikers' motion is achieved by two mechanisms that (are trying to) work together :
- flow fields make the pathfinding possible
- steering machine ensure that hikers flows smoothly throught obstacles
A third actor interposes to prevent hikers to collide with each other and with terrain.
Each time a hiker need to reach a destination, it asks the map to build a flow field. The flow field contains a movement vector for each map tile. The hiker as only to follow the flow at each step of its walk to reach destination.
Flow fields have two main advantages :
- only one computation for each destination, which is optimal for large groups to move
- flow is present everywhere, so a hiker that have been pushed away can always retrieve its path (or a better one)
the steering machine is called by each hiker at every frame. This very sensitive piece of code decides wich vector to apply to the hiker. There are many available behaviors :
- follow the flow field
- separate from neighbors
- align with neighbors
- stick to neighbors
- brake to let pass neighbors
And many objectives : reach destination, ovoid obstacles, let pass others, swarm with the group, occupy available space, etc. The calibration of the code is subtle because hikers have different sizes, speeds and objectives.
At this time, the steering machine only uses "follow flow field" and "separation" behaviors.
Once the steering machine has decided which vector to apply, the Collision Manager check for the feasibility of the intended motion. If the hiker will collide with an obstacle (terrain, solid trinket, blocking hiker), it seeks for a better vector to achieve a close movement.
The collision manager have a trying mechanism that allow a hiker to find it's way throught a group of blocking hikers (ennemies, or allies that are attaking and will not let pass). That mecahnism is not 100% reliable and a pathfinder may give better results for those local blockades.