Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. public void EvaluateSector(SectorTerrain sector, int fishCount)
  2. {
  3. //Debug.Log("EvaluateSector: (" + sector.x + ")(" + sector.z + ") NumFishes: " + fishCount);
  4.  
  5. int placedFishes = 0;
  6.  
  7. for (int i = 0; i < fishCount; i++)
  8. {
  9. float xMin = sector.x * sector.SectorBound;
  10. float xMax = sector.x * sector.SectorBound + sector.SectorBound;
  11.  
  12. float zMin = sector.z * sector.SectorBound;
  13. float zMax = sector.z * sector.SectorBound + sector.SectorBound;
  14.  
  15. Vector3 spawnPosition = new Vector3(Random.Range(xMin, xMax), fishHighPosition, Random.Range(zMin, zMax));
  16.  
  17. RaycastHit hit;
  18.  
  19. if (Physics.Raycast(spawnPosition, -Vector3.up, out hit, 1000.0f, 1 << LayerMask.NameToLayer("Terrain")))
  20. {
  21. if (hit.point.y + waterPlane.transform.position.y <= 3.0f)
  22. {
  23. ActivateFishObj(sector, spawnPosition, Quaternion.identity);
  24. placedFishes++;
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement