My Wall Jump Was Working Normally But I Were trying to add collider detector for my enemy then that happens : https://streamable.com/wjfftn Can you Guys Help Me With it this is my Wall Jump Script public float WallSlidForce;
public float WallJumpDuration = 0.3f;
private float WallSlideDirection;
private float WallJumpTimer = 0.2f;
private float WallJumpTime;
public bool IsWallSliding;
private bool IsWallJumping;
void Update()
{
if ( CanMove)
{
if (!IsCroushing )
rb.velocity = new Vector2(HorizontalMovement * WalkForce, rb.velocity.y);
else if (IsCroushing)
rb.velocity = new Vector2(HorizontalMovement * CroushForce, rb.velocity.y);
Flip();
}
Animation();
WallSliding();
WallJump();
MoveChecking();
}
public void Jump(InputAction.CallbackContext context)
{
if (context.performed && !IsDashing && !IsCroushing)
{
if (!IsWallSliding && JumpLeft > 0 && !Ck.IsGrounded)
{
rb.velocity = new Vector2(rb.velocity.x, JumpForce);
JumpLeft--;
Jump2 = true;
}
if (Ck.IsGrounded)
{
rb.velocity = new Vector2(rb.velocity.x, JumpForce);
}
}
else if (context.canceled)
rb.velocity = new Vector2(rb.velocity.x,rb.velocity.y * 0.5f);
if (context.performed && WallJumpTime > 0f && !IsCroushing)
{
if (HorizontalMovement != 0)
{
IsWallJumping = true;
rb.velocity = new Vector2(WallSlideDirection * WallJumpForce.x, WallJumpForce.y);
WallJumpTime = 0f;
}
else
{
IsWallJumping= true;
rb.velocity = new Vector2 (WallSlideDirection * WallJumpForce.x , rb.velocity.y);
WallJumpTime = 0f;
}
if (transform.localScale.x != WallSlideDirection)
{
IsFacingRight = !IsFacingRight;
Vector2 ls = transform.localScale;
ls.x *= -1f;
transform.localScale = ls;
}
Invoke(nameof(StopWallJump),WallJumpDuration);
}
if (context.performed && IsCroushing && !Ck.IsTouchingFloor)
{
rb.velocity = new Vector2(rb.velocity.x, JumpForce);
StopCroushing();
}
}
private void MoveChecking()
{
if (!IsWallSliding && !IsDashing && !IsSliding && !IsWallJumping && !IsAttacking)
CanMove = true;
else CanMove = false;
}
private void WallSliding()
{
if (Ck.IsTouchingWall && !Ck.IsGrounded && !IsDashing)
{
rb.velocity = new Vector2(rb.velocity.x, -WallSlidForce);
IsWallSliding = true;
}
else IsWallSliding = false;
}
private void WallJump()
{
if (IsWallSliding)
{
IsWallJumping = false;
WallSlideDirection = -transform.localScale.x;
WallJumpTime = WallJumpTimer;
CancelInvoke(nameof(StopWallJump));
}
else WallJumpTime -= Time.deltaTime;
}
private void StopWallJump()
{
IsWallJumping = false;
} enter image description here
I want To fix my problem a know why that happening.