Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void FixedUpdate()
- {
- Vector3 euler = rb.rotation.eulerAngles;
- float targetYRotation = euler.y + (inputDirection.x * Time.fixedDeltaTime * speedMult * rotaRatio);
- float maxTilt = 20f;
- float targetZTilt = Mathf.Clamp(inputDirection.x * -maxTilt, -maxTilt, maxTilt);
- if (inputDirection.x == 0f)
- {
- targetZTilt = 0f;
- wheelingDuration = 0f;
- }
- else
- {
- wheelingDuration += Time.DeltaTime;
- }
- float smoothedZTilt = Mathf.LerpAngle(euler.z, targetZTilt, wheelingDuration / duration);
- Quaternion newRotation = Quaternion.Euler(0f, targetYRotation, smoothedZTilt);
- rb.MoveRotation(newRotation);
- }
Advertisement
Add Comment
Please, Sign In to add comment