Scripting questions, discussions, etc
5 posts Page 1 of 1
Posts: 85
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Fri Mar 30, 2018 5:10 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?
Posts: 381
Joined: Mon Feb 09, 2015 7:48 pm
by chriscalef » Fri Mar 30, 2018 6: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.
Posts: 1242
Joined: Sun Feb 08, 2015 1:51 am
by Duion » Fri Mar 30, 2018 9:18 pm
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.
Site Admin
Posts: 408
Joined: Tue Feb 03, 2015 7:25 pm
by LukasPJ » Sat Mar 31, 2018 8:49 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.
Posts: 85
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Fri Apr 06, 2018 3:02 am
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>
5 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests