Skip to content

Instantly share code, notes, and snippets.

@sinistersnare sinistersnare/failRotate.cs Secret
Created Apr 10, 2019

Embed
What would you like to do?
plz help
Vector3 startingPosWorld = this.hookParent.position;
Vector3 mouse = Input.mousePosition;
Vector3 startingPos = Camera.main.WorldToScreenPoint(startingPosWorld);
Vector3 vectorToTarget = mouse - startingPos;
float angle = Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg;
Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward);
this.hookParent.transform.rotation = q;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.