Any way to find terrain in a region?

Is there any way know if there is terrain in a region3 or something similar to it? I am making a AI controlled plane that flys over terrain, and need a way to know if the ground is 10 studs under the plane, because if it is 9 studs or less it will fly up and if it’s 11 studs or up then it flys down. I have done this with baseparts already but I need to know how to do it with terrain.

I would use raycasting for this. Cast an infinite ray downwards from the plane. If terrain is below the plane, it will return the position where the ray hits the terrain. You can then just find the difference in height between plane and terrain.

1 Like

As ExtremeBuilder said, looking at your use case this is what rays are used for on Roblox. Cast a ray with a downwards direction for 11 studs and check for hits.

However if like your title suggests you need to find Terrain in a region. Terrain has a ReadVoxels function.

If the tuple returns only Air materials you know the region contains no ‘land’.

2 Likes

Adding on to @ExtremeBuilder15 you can also get the material of the terrain from that raycast as well if you so need.

Thank you. Now I can improve my current system.

If that post was the solution, remember to mark it as the solution!

I did mark it as the solution though