getTerrainHeight

Scripting questions, discussions, etc

getTerrainHeight

Hodo33
Posts: 13
Joined: Fri Dec 29, 2017 4:34 pm
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?

Re: getTerrainHeight

chriscalef
Posts: 374
Joined: Mon Feb 09, 2015 7:48 pm
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.

Re: getTerrainHeight

Duion
Posts: 957
Joined: Sun Feb 08, 2015 1:51 am

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.

Re: getTerrainHeight

LukasPJ
Posts: 367
Joined: Tue Feb 03, 2015 7:25 pm

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.

Re: getTerrainHeight

Hodo33
Posts: 13
Joined: Fri Dec 29, 2017 4:34 pm
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>

Who is online

Users browsing this forum: No registered users and 1 guest