Skip to content

Instantly share code, notes, and snippets.

@kennir
Created July 13, 2016 05:57
Show Gist options
  • Save kennir/1b545c55e2ab40d36ce536a1711d032d to your computer and use it in GitHub Desktop.
Save kennir/1b545c55e2ab40d36ce536a1711d032d to your computer and use it in GitHub Desktop.
RotateAround in Unity
void Update () {
//this.transform.RotateAround(this.transform.parent.position, this.transform.parent.up, 1);
MyRotateAround(this.transform.parent.position, this.transform.parent.up, 1);
}
void MyRotateAround(Vector3 pos, Vector3 up, float degree)
{
Quaternion q = Quaternion.AngleAxis(degree, up);
this.transform.position = q * (this.transform.position-pos) + pos;
this.transform.rotation *= q;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment