5 minutes
One capsule on an empty pitch is not a game. You need players in red and blue. That means six AI capsules. Chasing and shooting come in the next two lessons. First, each midfielder needs to know its place on the pitch: which third of the field is home.
AIZone gives a capsule that home. The capsule moves freely inside a set area. When it wanders too far, the zone gently pulls it back. You add this one component to four of the six capsules.
Add the players
Four midfielders each get a zone centered on their starting third. The two strikers start as plain physics bodies. Their AI comes later, in Lesson 8. Every capsule has the ai tag, so BallPossession already counts them. Each midfielder also gets a team:Red or team:Blue tag:
Add RedMidR (zone at [-7, 0, -5]), BlueMidL ([7, 0, 5]), and BlueMidR ([7, 0, -5]) as midfielders. Add BlueStriker (at [3, 1, 0]) as a plain body like RedStriker. The strikers have no AIZone. They will roam the whole pitch to hunt for the goal, so nothing holds them to one spot.
Continue reading
Unlock the Full Course
Every lesson, the runnable examples, and the finished build — yours to keep.