Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ApplyGravity()
- {
- if (isGravityDirectionSelected)
- {
- rb.useGravity = false;
- // Apply the new gravity direction relative to the player's rotation
- Vector3 adjustedGravityDirection = transform.TransformDirection(newGravityDirection);
- Physics.gravity = adjustedGravityDirection * Physics.gravity.magnitude;
- // Update the player's orientation
- UpdatePlayerOrientation(adjustedGravityDirection);
- // Update the camera's orientation
- UpdateCameraOrientation();
- // Reset the gravity application state
- ResetGravity();
- } else
- {
- rb.useGravity = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement