April 2021
Beginner to intermediate
506 pages
11h 57m
English
The thing about AI and autonomy is that once you give an object a little freedom, it’s no longer subject to your direct commands. Instead, it’s designed to think and act on its own. Sure, you may give it a goal, and it will attempt to meet that goal, but you’re no longer the one in charge.
Earlier, you “asked” the monsters to wander around by giving them a goal. So far, so good. The next goal you have for them is to chase Val, but only if she has a set of keys.
Still inside the AgentComponent.swift file, locate the following line:
| | agent.behavior = GKBehavior(goal: wanderGoal, weight: 100) |
and replace it with this one:
| | agent.behavior = GKBehavior(goals: [wanderGoal, interceptGoal], |
| | andWeights: [100, 0]) |
Now, instead ...
Read now
Unlock full access