void FixedUpdate() { target = targeting.Target; Vector3 dist = transform.position - target.transform.position; if (dist.magnitude < fleeRadius) { steering.Steer(dist); //flee hide.arriving = false; } else { Vector3 dir = hide.GetSteering(target.GetComponent <Rigidbody>(), obstacles, out hidePosition); //hide if (Vector3.Magnitude(transform.position - hidePosition) > hidingSpotRadius) { hide.arriving = true; steering.Steer(dir); } else if (hide.arriving) { hide.arriving = false; steering.Stop(); } } }
void FixedUpdate() { target = targeting.Target; if (Vector3.Magnitude(transform.position - target.transform.position) > targetRadius) { Vector3 followAccel = follow.GetSteering(target.GetComponent <Rigidbody>()); steering.Steer(followAccel); } else { steering.Stop(); } combat.Attack(target); }