x


Need help with terrainData.GetHeight

Hi,

I am trying to randomly place objects in the game and need to know what height the terrain has at a specific position. From what I understand terrainData -> GetHeight(x,y) is the way to do so. The documentation does not give much info on how to use this though.

Can anyone explain how this works or how to get what I am after?

Thanks in advance /Jens

more ▼

asked Oct 29 '10 at 10:42 PM

Jens 1 gravatar image

Jens 1
3 3 3 6

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You probably want Terrain.SampleHeight instead. If you have to use TerrainData for some reason, then you'd want GetInterpolatedHeight. The x and y values that you supply are normalized to the terrain, so that 0.0, 0.0 is the lower-left corner, and 1.0, 1.0 is the upper-right corner. See here.

more ▼

answered Oct 30 '10 at 12:37 AM

Eric5h5 gravatar image

Eric5h5
80.1k 41 132 519

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1464
x1089
x30
x6

asked: Oct 29 '10 at 10:42 PM

Seen: 1875 times

Last Updated: Oct 29 '10 at 10:42 PM