Adding treat eating cooldown

This commit is contained in:
hz
2026-01-31 19:44:21 -06:00
parent e4e385c5c2
commit 14ec7e81b2
5 changed files with 93 additions and 38 deletions
+25 -23
View File
@@ -83,31 +83,33 @@ public class PlayerPickupController : MonoBehaviour
Debug.Log(colliders.Length + " colliders found in range");
foreach (var col in colliders)
{
if (col.CompareTag("Interactable"))
if (!col.TryGetComponent<TrickController>(out var trick) && !col.CompareTag("Interactable"))
{
heldObject = col.gameObject;
// Parent the object to the HoldPoint and reset its local position
heldObject.transform.SetParent(holdPoint);
heldObject.transform.localPosition = Vector3.zero;
heldObject.transform.localRotation = Quaternion.identity;
// Disable physics so it doesn't fall or collide with the player
if (heldObject.TryGetComponent<Rigidbody2D>(out Rigidbody2D rb))
{
rb.bodyType = RigidbodyType2D.Kinematic;
rb.gravityScale = 0;
rb.mass = 0;
}
if (heldObject.TryGetComponent<TrickController>(out var trick))
{
trick.SetCarried(true);
}
if (col != null) col.enabled = false;
break;
continue;
}
heldObject = col.gameObject;
// Parent the object to the HoldPoint and reset its local position
heldObject.transform.SetParent(holdPoint);
heldObject.transform.localPosition = Vector3.zero;
heldObject.transform.localRotation = Quaternion.identity;
// Disable physics so it doesn't fall or collide with the player
if (heldObject.TryGetComponent<Rigidbody2D>(out Rigidbody2D rb))
{
rb.bodyType = RigidbodyType2D.Kinematic;
rb.gravityScale = 0;
rb.mass = 0;
}
if (trick != null)
{
trick.SetCarried(true);
}
if (col != null) col.enabled = false;
break;
}
}