Hi
I am trying to make a player controller script using the built in Character Controller and I need the player to smoothly move. Right now the player movement is very stiff. It instantly gets the speed I’ve set it to and instantly stops. I tried to pull some code from another rigidbody player I made before to smooth the movement but no luck. I have been searching all over the web and still no luck. So this is my last resort. I know this question have been asked tons of times but I can’t find anything that really works for me.
Here’s my current code at a attempt to smooth the movement.
cc = CharacterController.
moveDirection = Vector3.
-----
moveDirection = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= movementSpeed;
Vector3 targetMoveAmount = moveDirection * movementSpeed;
moveDirection = Vector3.SmoothDamp(moveDirection, targetMoveAmount, ref smoothMoveVelocity, .15f);
if (Input.GetKeyDown(movementSettings.jumpKey))
{
if (movementSettings.enableJumping && cc.isGrounded)
{
moveDirection.y = movementSettings.jumpForce;
}
}
moveDirection.y -= movementSettings.gravity * Time.deltaTime;
cc.Move(moveDirection * Time.deltaTime);
As I said before, this code moves the player but does not move it smoothly.
Any help is appreciated!
Also, if you have some extra time, I also need some help with the jumping. Right now if I try and jump is moves me back to the ground really fast. I followed the Unity docs for that so I have no idea why it would do that.