public void SetController(GameObject theController) { Controller = theController; BatFlockControl boidController = Controller.GetComponent <BatFlockControl>(); minDelay = boidController.minDelay; maxDelay = boidController.maxDelay; minVelocity = boidController.minVelocity; maxVelocity = boidController.maxVelocity; randomness = boidController.randomness; chasee = boidController.chasee; inited = true; }
private Vector3 Calc() { Vector3 randomize = new Vector3((Random.value * 2) - 1, (Random.value * 2) - 1, (Random.value * 2) - 1); randomize.Normalize(); BatFlockControl boidController = Controller.GetComponent <BatFlockControl>(); Vector3 flockCenter = boidController.flockCenter; Vector3 flockVelocity = boidController.flockVelocity; Vector3 follow = chasee.transform.localPosition; flockCenter = flockCenter - transform.localPosition; flockVelocity = flockVelocity - rb.velocity; follow = follow - transform.localPosition; return(flockCenter + flockVelocity + follow * 2 + randomize * randomness); }