using UnityEngine; public class Jump : MonoBehaviour { [SerializeField] GroundCheck groundCheck; Rigidbody rigidbody; public float jumpStrength = 2; public event System.Action Jumped; void Reset() { groundCheck = GetComponentInChildren(); if (!groundCheck) groundCheck = GroundCheck.Create(transform); } void Awake() { rigidbody = GetComponent(); } void LateUpdate() { if (Input.GetButtonDown("Jump") && groundCheck.isGrounded) { rigidbody.AddForce(Vector3.up * 100 * jumpStrength); Jumped?.Invoke(); } } }