Last active
November 10, 2024 05:59
-
-
Save johnsoncodehk/2ecb0136304d4badbb92bd0c1dbd8bae to your computer and use it in GitHub Desktop.
Unity Clamp Angle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static float ClampAngle(float angle, float min, float max) { | |
float start = (min + max) * 0.5f - 180; | |
float floor = Mathf.FloorToInt((angle - start) / 360) * 360; | |
return Mathf.Clamp(angle, min + floor, max + floor); | |
} |
You are amazing <3 Thank you
you helped me solve my problem with clamping angles in godot. Thank you so much.
thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
<3 (heart)