• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by LiTux · May 08, 2013 at 08:50 AM · terrainsizeterraindataslope

terrainData.GetSteepness() usage

How is GetSteepness() used? I just noticed, it accepts an x and y, not an x and z. This is confusing me. What z is used if x and y are given.

Also, I've normalized the coordinates based on terrainData.size. For some reason, it returns 1 as the steepness every time, even on sloped hills.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ebil · May 19, 2013 at 11:04 PM 0
Share

No help for you, but I also got a similar Problem, I always get 0 as result...

//Edit: Nevermind... forgot to normalize it...

I dont know what you mean by you used terrainData.size, but I normalized the Vector3 of a Raycast that I had from the terrain, since I dont know how your game works I cant tell you if it would be also a solution for you.

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Eric5h5 · May 20, 2013 at 12:15 AM

A terrain uses 2D data (namely, a heightmap); there is no Z used in the creation of a terrain. It's not relevant. Perhaps it would make more sense to specify X and Z, but in this case X and Y refer to the width and length.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
3

Answer by ArtOfWarfare · Dec 13, 2015 at 03:55 AM

When using GetSteepness(), you should provide your X and Z values in place of X and Y, and you should normalize them so that they're between 0 and 1. If your X and Z values have the same origin as the terrain but need to be normalized, you can use the following:

 float normalizedX = myX / terrainData.size.x;
 float normalizedY = myZ / terrainData.size.Z;

Now this part isn't documented anywhere, so this is why I really feel compelled to answer this question: GetSteepness() returns a float between 0.0 and 90.0 representing the Euler angle of the slope. This seemed like a bizarre choice to me - I had expected it to be a float between 0.0 and 1.0.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Dec 13, 2015 at 01:41 PM 0
Share

A value between 0 and 1 would actually be bizarre. What would it represent? Still an angle? If it's an angle you would use some kind of angle unit. So either degree (what they did) or radians. If you don't want to get back an angle but the actual slope, the returned value would represent the tangent of the angle and therefore would be in range 0.0 to +inf. A value of 1.0 would be 45°, a value of 2 would be 63.435° and "+inf" would be 90°.

You never represent an actual angle as a value between 0 and 1. That wouldn't make much sense.

ps: It's actually an ordinary angle and has no relation to Euler angles. Eulerangles describe an orientation within some kind of Euclidean space

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Bake terrain normal via script 0 Answers

How do I make my object follow the ground perfectly? 1 Answer

Object2Terrain Creates a Invalid Collider. Help please. 1 Answer

Make an instantiated object match the slope of the terrain 1 Answer

Terrain and PerlinNoise Glitch 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges