Question by 
               Cracle · Apr 18, 2018 at 08:22 PM · 
                physicsprogramming  
              
 
              How do I make my sliding smoother?
I've encountered a problem where my player object would slide of a cliff very roughly and bumpy. I've been following a tutorial that was filmed in 2010 found here. In the tutorial they use a gravity function that they write themselves and a character controller. My slide function uses a ray that shoots down to the ledge and return normal.y. Here is the code:
My Gravity function:
 void ApplyGravity()
     {
         if (MoveVector.y > -TerminalVelocity)
             MoveVector = new Vector3(MoveVector.x, MoveVector.y - Gravity * Time.deltaTime, MoveVector.z);
 
         if (TP_Controller.CharacterController.isGrounded && MoveVector.y < -1)
             MoveVector = new Vector3(MoveVector.x, -1, MoveVector.z);
 
     }
 
               My slide function:
 void ApplySlide()
     {
         if (!TP_Controller.CharacterController.isGrounded)
             return;
 
         SlideDirection = Vector3.zero;
 
         RaycastHit hitInfo;
         if (Physics.Raycast(transform.position, Vector3.down, out hitInfo))
         {
             if (hitInfo.normal.y < SlideThreshold)
                 SlideDirection = new Vector3(hitInfo.normal.x, -hitInfo.normal.y, hitInfo.normal.z);
         }
 
         if (SlideDirection.magnitude < MaxControllableSlideMagnitude)
             MoveVector += SlideDirection;
         else
         {
            MoveVector = SlideDirection;
         }
     
     }
 
               I don't know if this will help, but this is my motion process function:
 void ProcessMotion()
     {
         MoveVector = TP_Camera.Instance.transform.TransformDirection(MoveVector);
         MoveVector = new Vector3(MoveVector.x, 0, MoveVector.z);
 
         // Normalize MoveVector if Magnitude > 1
         if (MoveVector.magnitude > 1)
             MoveVector = Vector3.Normalize(MoveVector);
 
         //Apply Slide if applicable
         ApplySlide();
 
         //Multiply MoveVector by MoveSpeed
         MoveVector *= MoveSpeed;
 
         //Reapply VerticalVelocity MoveVector.y
         MoveVector = new Vector3(MoveVector.x, VerticalVelocity, MoveVector.z);
 
         //Apply gravity
         ApplyGravity();
 
         //Move the character in World Space
         TP_Controller.CharacterController.Move(MoveVector * Time.deltaTime);
 
     }
 
               Thank you for looking in to this post. If any more information would help i will provide it as soon as possible. Any idea of what could cause this problem would be appreciated.
               Comment
              
 
               
              Your answer