private void Update() { trackedBall = null; if (!doggo.WantsToPlay()) { return; } Collider[] balls = new Collider[3]; int count = Physics.OverlapSphereNonAlloc(myTransform.position, radius, balls, layerMask); if (count > 0) { for (int i = 0; i < count; i++) { Vector3 dir = Vector3.Normalize(balls[i].transform.position - myTransform.position); float dot = Vector3.Dot(dir, myTransform.forward); // 90º FOV if (dot >= 0f) { trackedBall = balls[i].gameObject; break; } } } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Treats")) { if (doggo.IsHoldingBall) { doggo.DropBall(); } doggo.EatTreat(other.gameObject); } else if (other.gameObject.CompareTag("Ball")) { if (doggo.WantsToPlay()) { doggo.FetchBall(other.gameObject); } } }