Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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
2
Question by juliobds · Aug 03, 2011 at 03:06 PM · terrainruntime-generationterrainsterraincollider

Terrain Collider doesn't update/ how to create a new terrain Collider?

Hi,

I'm trying to create an modify terrains at runtime. So far I've donne this:

 //Time to create the first terrain based on the template that is in the scene
         tempTerr = Instantiate(TerrainTemplate, new Vector3(2000.0f, 0.0f, 2000.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)) as Terrain;
         tempTerr.terrainData = Instantiate(TerrainTemplate.terrainData) as TerrainData;
         hMp = generateHeightmap(tempTerr.terrainData.GetHeights(0, 0, 513, 513), new Vector2(513.0f, 513.0f));    
         tempTerr.terrainData.SetHeights(0, 0, hMp);


At the moment the terrain is being created, and I can see the changes to the terrain (created by the generateHeightmap function). The Problem is that the player falls throught the terrain and stops at the bottom of the terrain(where the old terrain collider was(A flat terrainCollider)).

Bottom line: how do I update the terrain collider? The SetHeights function should do that but it doesn't. What can I do? A little/fast code example would be greatly appreciated.

Thanks for your time...

edit: I've already tried Flush() but nothing changed.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by roamcel · Aug 05, 2011 at 12:21 PM

I'm sorry if I can't be more helpful, but I believe you need to manually update the terraincollider, based on the new heightmap (never faced this problem so mine is basically a guess).

Comment
Add comment · Show 2 · 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 juliobds · Aug 05, 2011 at 03:39 PM 0
Share

Thanks for trying to help but the collider in the terrain is read only, ID$$anonymous$$ what else I can do, guys please help me xD

avatar image jc_lvngstn · Dec 15, 2011 at 01:10 AM 0
Share

I'm trying to find this out also. Did you ever find a solution to this?

avatar image
0

Answer by Darkgaze · Mar 26, 2019 at 11:18 AM

For anybody looking for help, in v 2017, 2018.. to update the TerrainCollider you have to update the heights on the terraindata of both the terrainCollider and the terrain. Seems like there is a copy. Changing the terrain only will update the visualization but not the collider itself.

 terrainCollider.terrainData.setHeights(...)
 terrain.terrainData.setHeights(...)

In v2019 the terrain has been moved to GPU and the API changed, so maybe this doesn't work. Seems like there is a function to update "dirty" data.

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

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.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Terrain Generation ruins collision 1 Answer

Access terrains "Alphamap 0" from within code 0 Answers

Terrain help 0 Answers

Terrain collider - add 2 Answers

Multiple terrain with different values 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges