Guest User

Untitled

a guest
Apr 24th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. private Vector3 PlaceOnCircle(Vector3 position) {
  2. Ray ray = Camera.main.ScreenPointToRay (position);
  3. Vector3 pos = ray.GetPoint (0f);
  4.  
  5. // Making 'pos' local to... ?
  6. pos = transform.InverseTransformPoint (pos);
  7.  
  8. float angle = Mathf.Atan2 (pos.x, pos.z) * Mathf.Rad2Deg;
  9. pos.x = circle.radius * Mathf.Sin (angle * Mathf.Deg2Rad);
  10. pos.z = circle.radius * Mathf.Cos (angle * Mathf.Deg2Rad);
  11. pos.y = 0f;
  12.  
  13. return pos;
  14. }
Add Comment
Please, Sign In to add comment