- Home /
 
 
               Question by 
               antonsimmerle · Apr 06 at 03:10 PM · 
                movementplayerjumpplayer movementdash  
              
 
              Dash in movement direction, not in forward direction
Hey guys, I implemented a jump-dash feature, but when I go backwards and dash, the player dashes forwards, instead I want him to dash backwards.
Here's the dash script:
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
     if (Input.GetKeyDown(KeyCode.LeftShift) && !isGrounded)
     {
         if(canDash == false)
         {
         currentDashTime = 0;
         canDash = true;
         }
     }
     if(currentDashTime < maxDashTime)
     {
         moveDirection = transform.forward * dashDistance;
         currentDashTime += dashStoppingSpeed;
     }
     else
     {
         moveDirection = Vector3.zero;
     }
     controller.Move(moveDirection * Time.deltaTime * dashSpeed);
     if(isGrounded)
     {
       canDash = false;
     }
 
               Thank you!
               Comment
              
 
               
              Instead of getting 'transform.forward' get the velocity vector.
Your answer