- Home /
 
How Can I Make The Parkour Moves Move Smoothly Instead Of Instantly Teleport?
I can't figure out why this sprint isn't working, and I'm also wondering how to make the controller.move move smoothly instead of teleportng? Thanks!
 var RunSpeed : float = 4.0;
 var SprintSpeed : float = 2.0;
 var JumpHeight : float = 6.0;
 
 var Gravity : float = 20.0;
 
 private var MoveDirection : Vector3 = Vector3.zero;
 
 private var ButtonA : boolean = false;
 private var ButtonD : boolean = false;
 private var ButtonS : boolean = false;
 
 
 
 function Start()
 {
     MoveSpeed = RunSpeed;
 }
 
 
 
 function Update()
 {
     var controller : CharacterController = GetComponent(CharacterController);
     
     if(Input.GetButton("A"))
     {
         ButtonA = true;
     }
     else
     {
         ButtonA = false;
     }
     
     if(Input.GetButton("D"))
     {
         ButtonD = true;
     }
     else
     {
         ButtonD = false;
     }
     
     if(Input.GetButton("S"))
     {
         ButtonS = true;
     }
     else
     {
         ButtonS = false;
     }
     
     
     
     if (controller.isGrounded)
     {
         MoveDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
         MoveDirection = transform.TransformDirection(MoveDirection);
         MoveDirection *= MoveSpeed;
             
         if(Input.GetButtonDown("Sprint") && !ButtonA && !ButtonD && !ButtonS)
         {
             MoveSpeed = RunSpeed * SprintSpeed;
         }
             
         if(Input.GetButtonUp("Sprint"))
         {
             MoveSpeed = RunSpeed;
         }
         
         if (Input.GetButton ("Jump"))
         {
             MoveDirection.y = JumpHeight;
         }
     }
     MoveDirection.y -= Gravity * Time.deltaTime;
 
     controller.Move(MoveDirection * Time.deltaTime);
 }
 
              Answer by Vonni · May 25, 2013 at 05:52 PM
You should try to not call inputs "A" "B" "C" etc. They are using strings so its easier to change the keybind by the user ( stick to forwards sideways etc ).
And you have an error in your script. In the sprint input, you have !ButtonA && !ButtonD && ButtonS . Unless you want the character to only sprint when running backwards first?
Yeah, I've since modified it so it the sprint works, but I forgot to change it, sorry, but thanks for answering anyway :)
I still need to find out how to make charactercontroller.move move smoothly a certain distance
Your answer
 
             Follow this Question
Related Questions
How to smooth movement object in one-axis? 1 Answer
Smooth Moving GameObject 1 Answer
How to move camera on an angle 1 Answer
move a gameobject to left/right while going up 1 Answer
Vector3.Slerp not working 2 Answers