Hello,
I’ve tried using OnCollisonEnter as well as OnTriggerEnter but to no avail. I am simply unable to make my player successfully jump. I believe I’ve narrowed it down to the Colliders not working.
I got Box Colliders and Rigidbody2D on both my player character and the ground.
I’m using the following code:
void Update()
{
playerMovement();
if(Input.GetKeyDown(KeyCode.Space) && isOnGround)
{
playerRb.AddForce(Vector2.up, ForceMode2D.Impulse);
isOnGround = false;
}
}
void OnCollisionEnter2D(Collision collision)
{
if (collision.gameObject.tag == "Ground")
{
isOnGround = true;
Debug.Log("Player has jumped");
}
}