//look for a fish to eat and speed towards that fish void BehaveHunting() { //does the fish have a target already? if (target) { //is the target still valid, can be invalid if on another w or has grown larger than this fish if (target.GetComponent <HyperColliderManager>().w == myHyper.w && target.GetComponent <Fish>().size <= size) { //move forwards while restricting speed _cachedTransform.Translate(Vector3.forward * Time.deltaTime * huntingSpeed); //smoothly turn towards the target location if (_cachedTransform.rotation != Quaternion.LookRotation(target.transform.position - _cachedTransform.position)) { _cachedTransform.rotation = Quaternion.Slerp( _cachedTransform.rotation, Quaternion.LookRotation(target.transform.position - _cachedTransform.position), Time.deltaTime * 10 ); } } else //look for a new target { target = fishManager.RequestTarget(gameObject, false); } } else //fish does not have a target //are there valid targets? { if (!noTargets) { target = fishManager.RequestTarget(gameObject, false); } else { BehaveHungry(); } } }