thombruce / verse

🚀 A universe in progress
Other
8 stars 0 forks source link

Steering Behaviours #65

Open thombruce opened 10 months ago

thombruce commented 10 months ago

Recently implemented the beginnings of an AI system for enemies in the game, but all it does right now is aggressively turn and fly towards the player. The inevitable result of this is that if the enemy aligns perfectly with the player, they will collide with and push the player (their desired state is to be precisely where the player is). Since high-speed collisions should be, y'know, dangerous, we should prefer that they steer to avoid the player and strafe during combat instead.

That's just one behaviour from a list of steering behaviours not yet implemented:

This list adopted from here: https://code.tutsplus.com/series/understanding-steering-behaviors--gamedev-12732 "Movement Manager" quoted and emphasised because it isn't really a steering behaviour, but a way to combine steering behaviours.

The guide linked above is very old and was written for Flash (so there are some demonstrations missing) but I did reference it when writing the initial seek behaviour, and I think it offers clear advice even if I do have to adapt it heavily.

We don't need to implement these behaviours all at once, though some do clearly follow from one another ("Leader Following" and "Queue"). The list is also incomplete, and we might well consider adding advanced behaviours like flocking, flanking or pincering, advanced routing or pathfinding, etc.

A more detailed and more advanced discussion of steering behaviours can be found here: https://www.red3d.com/cwr/steer/gdc99/


An ideal implementation would be comprised of several smaller code submodules which could be swapped between using a tag or marker system (change behaviour at the toggle of a component). This would make it more manageable, more reusable and more compatible with higher-level AI implementations like big-brain.