Skip to content

Instantly share code, notes, and snippets.

@DataGreed
Created April 27, 2019 20:33
Show Gist options
  • Select an option

  • Save DataGreed/b8701dc8f81052287bd16628e8019b7d to your computer and use it in GitHub Desktop.

Select an option

Save DataGreed/b8701dc8f81052287bd16628e8019b7d to your computer and use it in GitHub Desktop.
look at point
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