Advertisement
Guest User

bbb

a guest
Dec 17th, 2011
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. // Grab mouse position on terrain chunk and remove the appropriate cube
  2.  
  3. Ray ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width/2, Screen.height/2)); //Input.mousePosition);
  4.  
  5. RaycastHit hit = new RaycastHit();
  6.  
  7.  
  8.  
  9. if (collider.Raycast(ray, out hit, 10.0f))
  10.  
  11. {
  12.  
  13. Vector3 hp = hit.point + 0.0001f * ray.direction;
  14.  
  15.  
  16.  
  17. int xHit = Mathf.CeilToInt(hp.x) - 1;
  18.  
  19. int yHit = Mathf.CeilToInt(hp.y) - 1;
  20.  
  21. int zHit = Mathf.CeilToInt(hp.z) - 1;
  22.  
  23.  
  24.  
  25. TerrainBrain.Instance().setTerrainDensity(xHit, yHit, zHit);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement