Created
April 27, 2019 20:33
-
-
Save DataGreed/b8701dc8f81052287bd16628e8019b7d to your computer and use it in GitHub Desktop.
look at point
This file contains hidden or 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 void LookAtPoint2d(Vector2 targetPoint, int degreesCompensation=0) | |
| { | |
| Vector3 dir = (targetPoint - (Vector2)transform.position).normalized; | |
| float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - degreesCompensation; | |
| torsoAnimator.gameObject.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment