# 3d wall jumping with charter controller

im making a 3d Platformer with unity’s built-in charter controller and no mater what I try I can’t seem to get wall jumping right. The player jumps but he doesn’t jump off the wall to the opposite side he just stays on the wall. NOTE: this is not the entire script because the script is too long to include it all so I only included the parts that involve the wall jump. This is what I have:

``````void OnControllerColliderHit(ControllerColliderHit hit)
{
hitNormal = hit.normal;
}
``````
• void WallJump()
{
velocity.y = Mathf.Sqrt(maxJumpHight * -2 * gravity);
animator.SetBool(“Jumping”, true);
wallJumping = true;
woosh1.Play();
jump.Play();
movingPlatform.enabled = false;
canMove = false;
StartCoroutine(CanMoveAgain());
}

``````float horizontal = moveing.x;
float vertical = moveing.y;
Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;

if (direction.magnitude >= 0.1f && canMove)
{
if (wallJumping == true)
{
direction = -hitNormal;
controller.Move(hitNormal * speed * Time.deltaTime);
}
if (!wallJumping == true)
{

float targetAngle = Mathf.Atan2(-direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y;
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
transform.rotation = Quaternion.Euler(0f, angle, 0f);

Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;
controller.Move(moveDir.normalized * speed * Time.deltaTime);
}
}
``````

it just doesn’t work what do I do?

Edit:
Think I found your problem. In WallJump you do:

canMove = false;
but then your code to move in the direction of the wall normal is inside this if statement:
if (direction.magnitude >= 0.1f && canMove)
which requires canMove to be true. You either need to change the if statement, move the wall jump code outside of it, or not set canMove to false.

`````` WallJump();