private void Move()
{
.................
_animationBlend = Mathf.Lerp(_animationBlend, targetSpeed, Time.deltaTime * SpeedChangeRate);
if (_animationBlend < 0.01f) _animationBlend = 0f;
Vector3 inputDirection = new Vector3(moveInput.x, 0f, moveInput.y).normalized;
if (moveInput != Vector2.zero)
{
_targetRotation = Mathf.Atan2(inputDirection.x, inputDirection.z) * Mathf.Rad2Deg +
_mainCamera.transform.eulerAngles.y;
float rotation = Mathf.SmoothDampAngle(transform.eulerAngles.y, _targetRotation,
ref _rotationVelocity, RotationSmoothTime);
transform.rotation = Quaternion.Euler(0f, rotation, 0f);
}
Vector3 targetDirection = Quaternion.Euler(0f, _targetRotation, 0f) * Vector3.forward;
_controller.Move(targetDirection.normalized * (_speed * Time.deltaTime) * rootMotionSpeedMultiplier +
new Vector3(0f, _verticalVelocity, 0f) * Time.deltaTime);
if (_hasAnimator)
{
_animator.SetFloat(_animIDSpeed, _animationBlend);
_animator.SetFloat(_animIDMotionSpeed, inputMagnitude);
}
}
This is a move function.
I want to use it with root motion (walking in place).
Currently, there's a jerky issue when the animation plays along with the movement.
I believe this is a conflict between the movement of the animation itself (root motion) and movement via keyboard input.
How can I fix this?