using UnityEngine; public class Draggable : MonoBehaviour { private Camera cam; private Rigidbody rb; private float fixedZ; private bool isOverMouth = false; void Start() { cam = Camera.main; rb = GetComponent(); fixedZ = transform.position.z; } void OnMouseDown() { rb.useGravity = false; rb.velocity = Vector3.zero; } void OnMouseDrag() { Vector3 mousePos = Input.mousePosition; mousePos.z = fixedZ - cam.transform.position.z; Vector3 worldPos = cam.ScreenToWorldPoint(mousePos); transform.position = new Vector3(worldPos.x, worldPos.y, fixedZ); } void OnMouseUp() { rb.useGravity = true; if (isOverMouth) { bool accepted = FeedingManager.Instance.TryFeed(); if (accepted) { Destroy(gameObject); // Only destroy if feeding accepted } } } void OnTriggerEnter(Collider other) { if (other.CompareTag("Mouth")) { isOverMouth = true; } } void OnTriggerExit(Collider other) { if (other.CompareTag("Mouth")) { isOverMouth = false; } } }