Question by
BenCourtemanche · May 31 at 10:26 AM ·
rigidbody2dvelocity
Unity Rigidbody2D bug
There’s a bug where if I jump up the ladder and then grab onto the ladder heading down, when the player hits the ground the velocity doesn’t go to zero instead its at 4.6. Is this a Unity bug or did I do something wrong?
Video: https://youtu.be/JCC6d2kSCkE
This is the climbing-down code:
void OnClimbingDOWN ( InputValue value )
{
if(capsuleCollider2D.IsTouchingLayers(LayerMask.GetMask("Ladder")))
{
Vector2 climbVelocityDOWN = new Vector2(rb2D.velocity.x, moveInput.y * climbSpeedDOWN * -1);
rb2D.velocity = climbVelocityDOWN;
rb2D.gravityScale = 0f;
bool playerHasVerticalSpeed = Mathf.Abs(rb2D.velocity.y) > Mathf.Epsilon;
animator.SetBool("IsClimbing", playerHasVerticalSpeed);
Debug.Log("ClimbingDOWN");
}
}
Comment