using UnityEngine;

public class PlayerJump : MonoBehaviour
{
    public float JumpForce = 5;

    public Transform GroundCheck;
    public float GroundCheckRadius = 0.2f;

    private Rigidbody m_rigidbody;
    private PlayerInputController input;

    private void Awake()
    {
        m_rigidbody = GetComponent<Rigidbody>();
        input = GetComponent<PlayerInputController>();
    }

    private void Update()
    {
        if (input.JumpPressed)
        {
            Jump();
        }
    }

    public void Jump()
    {
        if (Physics.CheckSphere(GroundCheck.position, GroundCheckRadius, LayerMask.GetMask("Ground")))
        {
            m_rigidbody.AddForce(Vector3.up * JumpForce, ForceMode.Impulse);
        }
    }
}