Jump to content

Recommended Posts

Posted

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?

Posted

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.

Posted

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.

Posted

I know this has already been answered, but here is a bad Paint image explaining it again:


tw21ZU6.png


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.

Posted

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>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...