- Home /
 
Move player along mesh
I'm making a parkour game, and when I'm hanging from a ledge I want to lock my players movement so I can only move along the ledges mesh. How would I go about doing this?
It's an fps game, and my FirstPersonController looks like this: void Update () { //Movement float h = Input.GetAxisRaw("Horizontal") movementSpeed; float v = Input.GetAxisRaw("Vertical") movementSpeed;
             //Jumping
             if(cc.isGrounded && Input.GetKeyDown(KeyCode.Space))
             {
                 verticalVelocity = jumpSpeed;
             }
 
         //Rotation
         rotX = Input.GetAxisRaw("Mouse X") * mouseSensitivity;
         rotY -= Input.GetAxisRaw("Mouse Y") * mouseSensitivity;
 
         xVelocity = Mathf.Lerp(xVelocity, rotX, snappiness * Time.deltaTime);
         yVelocity = Mathf.Lerp(yVelocity, rotY, snappiness * Time.deltaTime);
 
         if (!lockMouseMovement)
         {
             //RotY
             rotY = Mathf.Clamp(rotY, -upDownRange, upDownRange);
             mainCam.transform.localRotation = Quaternion.Euler(yVelocity, 0, 0);
 
             //RotX
             transform.Rotate(0, xVelocity, 0);
         }
 
         //Gravity
         if (!cc.isGrounded)
         {
             verticalVelocity += Physics.gravity.y * Time.deltaTime * 3f;
         }
 
         //Velocity
         velocity = new Vector3(h, verticalVelocity, v);
         velocity = transform.rotation * velocity;
 
         if (!lockMovement)
         {
             cc.Move(velocity * Time.deltaTime);
         }
     }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
MouseWheel Lerp Smoothing Problem 1 Answer
how to lock the z axis rotation 2 Answers
Character Axes Rotation Problem 3 Answers