Advertisement
DugganSC

Untitled

Jul 20th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. void ApplyGravity()
  2. {
  3. if (isGravityDirectionSelected)
  4. {
  5. rb.useGravity = false;
  6. // Apply the new gravity direction relative to the player's rotation
  7. Vector3 adjustedGravityDirection = transform.TransformDirection(newGravityDirection);
  8. Physics.gravity = adjustedGravityDirection * Physics.gravity.magnitude;
  9.  
  10. // Update the player's orientation
  11. UpdatePlayerOrientation(adjustedGravityDirection);
  12.  
  13. // Update the camera's orientation
  14. UpdateCameraOrientation();
  15.  
  16. // Reset the gravity application state
  17. ResetGravity();
  18. } else
  19. {
  20. rb.useGravity = true;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement