fix: player now jumps normally

This commit is contained in:
KOSMOGOR
2025-04-24 14:02:23 +03:00
parent de6739cdfa
commit 851ee23092
3 changed files with 35 additions and 11 deletions
+4 -3
View File
@@ -2,13 +2,14 @@ using UnityEngine;
public class GroundDetector : MonoBehaviour
{
public LayerMask groundMask;
public bool onGround { get; private set; } = false;
void OnTriggerEnter(Collider other) {
if (other.CompareTag("Ground")) onGround = true;
public void OnTriggerEnter(Collider other) {
if ((1 << other.gameObject.layer & groundMask) != 0) onGround = true;
}
void OnTriggerStay(Collider other) { OnTriggerEnter(other); }
void OnTriggerExit(Collider other) {
if (other.CompareTag("Ground")) onGround = false;
if ((1 << other.gameObject.layer & groundMask) != 0) onGround = false;
}
}
-3
View File
@@ -10,9 +10,6 @@ public class PlayerMovement : MonoBehaviour
[Header("Vertical movement")]
public float jumpForce = 1f;
public float gravityMultiplier = 1f;
public Transform legsPosition;
public float legsRadius = 0.5f;
public LayerMask groundMask;
[Header("Debug info")]
[SerializeField] bool isCrouching = false;