Hey there guys…greetings from me…
i am have following code for my character controller and it works fine but not only for air…while character controller is in air it flickers…please anyone help me to fix it…thanks
{
if (grounded) {
moveDirection = Vector3(inputX , 0, inputY );
moveDirection = myTransform.TransformDirection(moveDirection) * speed;
//Jumping
if (!Input.GetButton("Jump")
moveDirection.y = jumpSpeed;
}
}
else {
//problem is here...it goes in random place
moveDirection.x += inputX * speed/2 ;
moveDirection.z += inputY * speed/2 ;
moveDirection = myTransform.TransformDirection(moveDirection);
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller, and set grounded true or false depending on whether we're standing on something
grounded = (controller.Move(moveDirection * Time.deltaTime) & CollisionFlags.Below) != 0;
}