Adding treat eating cooldown
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user