Eonirr

Untitled

Mar 5th, 2025
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. void FixedUpdate()
  2. {
  3. Vector3 euler = rb.rotation.eulerAngles;
  4.  
  5. float targetYRotation = euler.y + (inputDirection.x * Time.fixedDeltaTime * speedMult * rotaRatio);
  6.  
  7. float maxTilt = 20f;
  8. float targetZTilt = Mathf.Clamp(inputDirection.x * -maxTilt, -maxTilt, maxTilt);
  9.  
  10. if (inputDirection.x == 0f)
  11. {
  12. targetZTilt = 0f;
  13. wheelingDuration = 0f;
  14. }
  15. else
  16. {
  17. wheelingDuration += Time.DeltaTime;
  18. }
  19.  
  20. float smoothedZTilt = Mathf.LerpAngle(euler.z, targetZTilt, wheelingDuration / duration);
  21.  
  22. Quaternion newRotation = Quaternion.Euler(0f, targetYRotation, smoothedZTilt);
  23. rb.MoveRotation(newRotation);
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment