vitorfgd

SpawnCircle

Jan 25th, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SpawnCircleNew : MonoBehaviour {
  5.  
  6. int numObjects = 12;
  7. public GameObject prefab;
  8.  
  9. void Start() {
  10.  
  11. Vector3 center = transform.position;
  12. for (int i = 0; i < numObjects; i++) {
  13. int a = i * 30;
  14. Vector3 pos = RandomCircle(center, 2.0f ,a);
  15. Instantiate(prefab, pos, Quaternion.identity);
  16. }
  17. }
  18.  
  19. Vector3 RandomCircle(Vector3 center, float radius,int a)
  20. {
  21. Debug.Log(a);
  22. float ang = a;
  23. Vector3 pos;
  24. pos.x = center.x + radius * Mathf.Sin(ang * Mathf.Deg2Rad);
  25. pos.y = center.y + radius * Mathf.Cos(ang * Mathf.Deg2Rad);
  26. pos.z = center.z;
  27. return pos;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment