Hodo33 Posted March 30, 2018 Share Posted March 30, 2018 I am trying to place an object on the ground in the game. Using getTerrainHeight(%x,%y) or getTerrainHeight(%x SPC %y) returns a z value not even close to the actual z. Is this a bug or am I doing something wrong? Quote Link to comment Share on other sites More sharing options...
chriscalef Posted March 30, 2018 Share Posted March 30, 2018 That function returns the height relative to the height of the terrain object itself, so if your terrain block is not at zero on the Z axis then the actual value will be the terrain's Z value plus the getTerrainHeight() value. Quote Link to comment Share on other sites More sharing options...
Duion Posted March 30, 2018 Share Posted March 30, 2018 The terrain is not flat, it is actually a cube and the terrain can exist at the bottom, middle, or top of the cube. For example a 1024x1024 terrain at the middle would have to be put at -512 on the Z-axis so the actual terrain is at Z-axis = 0 coordinate. Quote Link to comment Share on other sites More sharing options...
LukasPJ Posted March 31, 2018 Share Posted March 31, 2018 I know this has already been answered, but here is a bad Paint image explaining it again:The terrain block has some position, that position indicates the location of one of its corners (I believe), and the terrain stretches out from that position.You only have the height of the terrain at some specific point, but in order to get the world-coordinates, you need to take that terrain height, and offset it by the z-position of the terrain giving you the \(z\)-coordinate. Quote Link to comment Share on other sites More sharing options...
Hodo33 Posted April 6, 2018 Author Share Posted April 6, 2018 Ok yer right, my bad.... I use a 128 gray and set z to 0 and it always works, artist didn't follow that rule. Thanks to all for the reply < slaps forehead> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.