Hey Guys, Im using the code below to make the character move. It automatically jumps when it lands on platforms but it shakes/jitters specially when the player is going down and i cant work out why… The character is a cube and doesnt have any extra colliders besides character controller.
void Start ()
{
control = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update ()
{
distanceTraveled = transform.localPosition.x;
score += Time.deltaTime * 20;
move = new Vector3 (Input.GetAxis("Horizontal"),0f,0f);
move *= playerSpeed;
if(Input.GetKey(KeyCode.LeftArrow))
{
transform.forward = new Vector3(0f, 0f, -1f);
}
if(Input.GetKey(KeyCode.RightArrow))
{
transform.forward = new Vector3(0f, 0f, 1f);
}
if (!control.isGrounded)
{
gravity += Physics.gravity * fallSpeed * Time.deltaTime;
}
else
{
gravity = Vector3.zero;
gravity.y = jumpSpeed;
}
move += gravity;
control.Move(move * Time.deltaTime);
}