Checking if ground is flat with GetHeights()
I'm trying to check if ground under my instantiated object is flat enough to place it, but while trying to get my array of heights under my object all i get is ArgumentException: trying to acces out-of-bounds terrain height information, while im pretty sure it should be ok. my code
bool CheckIfFlat()
{
var BoxCollider = Tower.GetComponent<BoxCollider>();
var terrain = FindObjectOfType<Terrain>();
float[,] heights = terrain.terrainData.GetHeights((int)BoxCollider.bounds.min.x, (int)BoxCollider.bounds.min.y, (int)BoxCollider.size.x, (int)BoxCollider.size.y);
//i get that error here
Comment
Your answer
Follow this Question
Related Questions
Changing CharacterController's height causes jittering issue in Unity 0 Answers
unity terrain apply texture by altitude 0 Answers
How to detect surrounding terrain height for minimap (comparable to a sonar) 0 Answers
Greyscale in Raw-format doesn't control heightmap properly (5.6.3f1) 0 Answers
How to combine meshes seamlessly? 2 Answers