Trying to fix the issue where players get pinched through the floor
This commit is contained in:
@@ -17,6 +17,7 @@ public class PlayerPickupController : MonoBehaviour
|
||||
[SerializeField] private float throwChargeTime = 0.75f;
|
||||
[SerializeField] private float throwUpwardForce = 0f;
|
||||
[SerializeField] private float throwTriggerThreshold = 0.6f;
|
||||
[SerializeField] private float dropClearance = 0.2f;
|
||||
|
||||
[Header("Setup")]
|
||||
public Transform holdPoint; // Empty GameObject above head
|
||||
@@ -165,6 +166,11 @@ public class PlayerPickupController : MonoBehaviour
|
||||
{
|
||||
heldPickup.enabled = false;
|
||||
}
|
||||
if (heldObject.TryGetComponent<Rigidbody2D>(out var heldBody))
|
||||
{
|
||||
heldBody.linearVelocity = Vector2.zero;
|
||||
heldBody.angularVelocity = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (col != null) col.enabled = false;
|
||||
@@ -214,6 +220,7 @@ public class PlayerPickupController : MonoBehaviour
|
||||
throwBody.linearVelocity = new Vector2(direction * throwSpeed, 0f);
|
||||
throwBody.angularVelocity = 0f;
|
||||
}
|
||||
heldObject.transform.position += Vector3.up * dropClearance;
|
||||
Collider2D col = heldObject.GetComponent<Collider2D>();
|
||||
if (col != null) col.enabled = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user