Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public int spawnPoints = 30;
  2.  
  3. public GameObject spawnLocation;
  4.  
  5. void Awake()
  6. {
  7. RaycastHit hit;
  8.  
  9. for(int i=0;i<spawnPoints ;i++)
  10. {
  11. Vector3 position = new Vector3(Random.Range(-100.0f, 100.0f), 0, Random.Range(-100.0f, 100.0f));
  12. if (Physics.Raycast (position + Vector3 (0, 500.0f, 0), Vector3.down, out hit, 200.0f)) {
  13. Instantiate (spawnLocation, hit.point, Quaternion.identity);
  14. } else {
  15. Debug.Log ("there seems to be no ground at this position");
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement