November 2018
Beginner
246 pages
5h 23m
English
Now, it is time to create the controller class. This class updates its own position so that the other individual boid objects know where to go. The origin variable in the preceding UnityFlock script contains a reference to this object.
The following is the code in the UnityFlockController.cs file:
using UnityEngine; using System.Collections; public class UnityFlockController : MonoBehaviour { public Vector3 offset; public Vector3 bound; public float speed = 100.0f; private Vector3 initialPosition; private Vector3 nextMovementPoint; // Use this for initialization void Start () { initialPosition = transform.position; CalculateNextMovementPoint(); } // Update is called once per frame void Update () { transform.Translate(Vector3.forward ...Read now
Unlock full access