void FixedUpdate() { Vector3 accel = Vector3.zero; accel += separation.GetSteering(sensor.targets) * separationWeight; accel += velocityMatching.GetSteering(sensor.targets) * velocityMatchWeight; if (accel.magnitude < 0.005f) { accel = wander.GetSteering(); } steering.Steer(accel); steering.LookWhereGoing(); }
void LateUpdate() { Vector3 targetPos; Vector3 offsetAccel = offsetPursue.GetSteering(target, offsetDistance, out targetPos); Vector3 seperationAccel = separation.GetSteering(sensor.targets); steering.Steer(offsetAccel + seperationAccel); if (Vector3.Distance(transform.position, targetPos) > lookDistance) { steering.LookWhereGoing(); } else { steering.LookAtDirection(target.Rotation); } }