Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 shoeshine1984 · Dec 08, 2013 at 05:58 AM · collisionterrainprefabtree

Instantiated terrain tree collision not working

Hello all!

I'm trying to make a game that loads prefab terrains at run time, triggered by various conditions (such as where the player camera is). I noticed that if I "preload" the terrain (meaning the terrain is already in the scene when game starts as opposed to instantiating prefab), then the tree collision and terrain collision are both working.

However if I instantiate the terrain prefab during run time, terrain collision works but tree collision doesn't. The way I test it is by moving a rigidbody gameobject with AddForce command, and let it fly towards the tree. The object simply passes through the tree but will bounce upon touching the terrain.

Is this a known issue?

Thanks! :)

Comment
Add comment · Show 2
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 shoeshine1984 · Dec 08, 2013 at 06:15 AM 0
Share

I just tested another way by manually place the tree prefab in the scene, put it under the terrain gameobject and save the whole thing as a prefab (terrain + many trees). This time after the terrain and trees are instantiated in the scene, collision worked fine.

avatar image shoeshine1984 · Dec 08, 2013 at 06:21 AM 0
Share

It seems like there may be a unity bug where when the terrain is instantiated, the tree colliders are not added to the terrain. I cannot use the workaround of manually place trees one by one since I still depend on unity terrain system to add wind and billboard effect to the trees.

1 Reply

· Add your reply
  • Sort: 
avatar image
5

Answer by shoeshine1984 · Dec 08, 2013 at 09:49 AM

I figured it out. When you instantiate the terrain, you need to reset the terrain collider like this:

         newTerrain.collider.enabled = false;
         newTerrain.collider.enabled = true;

And then the tree colliders will be generated. Hope Unity puts this in the documentation one day!

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 Eldoir · Dec 08, 2017 at 03:14 PM 1
Share

You are my god. Saved me tons of time. Thanks! :D

avatar image CaseyHofland · Feb 28, 2021 at 09:26 AM 0
Share

This the dumbest, stupidest advice ever. It is even dumber and stupider that it actually works! Thank you!!!!!

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

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

Destroy Terrain Trees And They Collider 0 Answers

How do I make a tree have two collision capsules? 1 Answer

terrain tree collision ... huge list of trees in hirarchy 0 Answers

Terrain Trees with Custom Script 2 Answers

Swap tree prefabs at runtime 1 Answer


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