The flock target

Last, but not least, we have our flock target. To reiterate, you can use any art you like, or you can stick with the handsome little sphere in the provided sample project. The code for the target component is in the TargetMovement.cs file. The contents look like this:

using UnityEngine;public class TargetMovement : MonoBehaviour {    [SerializeField]    private Vector3 bounds;    [SerializeField]    private float moveSpeed = 10.0f;    [SerializeField]    private float turnSpeed = 3.0f;    [SerializeField]    private float targetPointTolerance = 5.0f;    private Vector3 initialPosition;    private Vector3 nextMovementPoint;    private Vector3 targetPosition;        private void Awake()     {        initialPosition = transform.position;        CalculateNextMovementPoint();    } private ...

Get Unity 2017 Game AI Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.