reeseschultz / ReeseUnityDemos

Unity packages and demos—emphasizing ECS, jobs and the Burst compiler—by Reese and others.
https://reese.codes
MIT License
516 stars 45 forks source link

Feat/flocking #70

Closed 0x6c23 closed 3 years ago

0x6c23 commented 3 years ago

I added the NavQuadrantSystem so we only steer away from neighbors in our quadrant. I also renamed the NavLerpSystem to NavSteeringSystem and added a NavSteering component. The NavSteeringSystem gets the steering vectors from the FlockingSystem and calculates a new heading for the entity.

The new NavMoveSystem will take this heading and apply it to the entity, aswell as calculate an appropriate rotation for the entity, so it will face the direction of movement with all steering behaviors included. I also added FlockingSettings to the NavSystem and additional settings to the NavAgent. The sequence of the jobs was changed so they work with the new systems.

Oh, I added a gif, as well.

There might be errors/ flaws in my code, please highlight them to me.

Yet to be implemented:

The steering behaviors can push entities into walls, might add some raycasting to prevent that if that sounds like a good idea?

Also, I suggest rewriting the follow system so it provides an additional (weighted) steering vector for the NavSteeringSystem. So it would be more flexible.

0x6c23 commented 3 years ago

Alright, I pushed the requested changes. Will open a new pull request for the extra raycasting + steering elements. Thanks for your comments!