G'day guys, yes me again...
Just trying to get my head around this bit of code which Bombardir used in his Build Blocker mod - I'm wanting to have the ability in part of my mod, to spawn something either at a certain height above the ground(terrain), or above water if there is any.
I'm just not sure how to differentiate between terrain height and water height, I've gone through this code block a couple of times and don't seem to get it. Is TerrainMeta.HeightMap.GetHeight treating water surface, and dry terrain as the same thing?
I guess what I'm asking then, is how can I find the distance between a river- or lake-bed and the surface of the water?
Any help much appreciatedCode:Vector3 Pos = StartBlock.transform.position; if (CheckHeight || CheckWater) { float height = TerrainMeta.HeightMap.GetHeight(Pos); if (CheckHeight && Pos.y - height > MaxHeight) { sender.ChatMessage(MsgHeight); StartBlock.Kill(BaseNetworkable.DestroyMode.Gib); return; } else if (CheckWater && height < 0 && height < MaxWater && Pos.y < 2.8f ) { sender.ChatMessage(MsgWater); StartBlock.Kill(BaseNetworkable.DestroyMode.Gib); return; } }![]()
Find water height at given map position
Discussion in 'Rust Development' started by Gliktch, Dec 26, 2015.
-
It's old code. As far as i know rust have new water detection.
-
Okay thank you. I'll see if I can work it out. I guess Terrainheight is mostly enough for what I'm doing right now
