Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.InputSystem;
- [RequireComponent(typeof(PlayerInput))]
- public class Jump : MonoBehaviour
- {
- [SerializeField] private float _jumpForce;
- private bool _isGrounded;
- public void OnJump()
- {
- if (_isGrounded)
- {
- Debug.Log($"Jump");
- }
- }
- private void OnCollisionEnter2D(Collision2D collision)
- {
- if (collision.collider.TryGetComponent(out Ground ground))
- {
- _isGrounded = true;
- }
- }
- private void OnCollisionExit2D(Collision2D collision)
- {
- if (collision.collider.TryGetComponent(out Ground ground))
- {
- _isGrounded = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement