Uplink001
Uplink001

Reputation: 69

Gameplaykit: agents goals and weights

I'm trying to set up my enemies behaviors so that they will chase the player, while avoiding obstacles (walls and such) and stay sufficiently separated from one another (partial flocking). What I want is for the enemies to get in contact with the player without overlapping one another. If I set my seek goal higher than the separate goal that's exactly what happens: enemies will chase the player but will also overlap perfectly to the point you won't be able to distinguish them. If I set my separate goal higher than the chase goal, they will chase the player and stay separated all the while but once they have reached him they'll just spin around their position instead of keep going for him.

Any tips? Here's my code (I'm not using align and cohere rules right now):

let enemyGoals = GKBehavior(goals: [
  alignGoal,
  cohereGoal,
  separateGoal,
  chaseGoal,
  avoidGoal
]);

// enemyGoals.setWeight(90, for: chaseGoal);
// enemyGoals.setWeight(95, for: avoidGoal);
enemyGoals.setWeight(100, for: separateGoal);

enemyHead.agent.behavior = enemyGoals;
agentSystem.addComponent(enemyHead.agent);

Upvotes: 0

Views: 184

Answers (0)

Related Questions