Last active
May 1, 2021 07:00
-
-
Save daichi-takezawa/d24c1b30fb737b3ae500f4b74926d47f to your computer and use it in GitHub Desktop.
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
Vector2 startPos,endPos; | |
void Flick() { | |
if (Input.GetKeyDown(KeyCode.Mouse0)) { | |
startPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); | |
} | |
if (Input.GetKey(KeyCode.Mouse0)) { | |
endPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); | |
Vector2 dt = endPos - startPos; | |
float radian = Mathf.Atan2(dt.x, dt.y) * Mathf.Rad2Deg; | |
//このままだとradianは180度と-180度表記になってしまうので下で解決する。 | |
if (radian < 0) { | |
radian += 360; | |
} | |
Debug.Log(radian); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment