Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by EssyTech · Sep 28, 2013 at 05:58 AM · collisionterrainoncollisionentertree

Terrain Trees with Custom Script

I have a tree prefab with a script attached to it. The tree prefab has a capsule collider attached to it and set properly around the tree. I have a character object with a collider attached to it as well. Here is my issue:

I am using the OnCollisionEnter. I placed the tree manually into the terrain and play the game. The result was that the OnCollisionEnter was executed, just as I wanted. I then added the tree using the terrain tool and painted a few of these trees onto the terrain. I was able to collide with the trees, however, the OnCollisionEnter event was not fired. Is there a reason why this event does not fire? or am I simply doing something incorrect?

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 Hoeloe · Sep 28, 2013 at 09:16 AM

There is a checkbox on the terrain script that says: "Generate Tree Colliders". It is a really badly labelled box, as it should really say: "Enable Tree Colliders". Unless that box is checked, colliders will be omitted from any trees you place.

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 EssyTech · Sep 28, 2013 at 02:22 PM 0
Share

Yes I do know this. As stated, the collider's do occur when I paint the trees on the terrain. However, the collisionevent does not fire. I have a debug.log output in the event and it works as a single tree, dragged and dropped on terrain. When I paint the trees using the terrain tools and I collide with the tree I do not get an output. That is my issue.

avatar image Hoeloe · Sep 28, 2013 at 02:31 PM 1
Share

Ah, I see. I think the issue then is probably that when colliders are attached to trees in the terrain engine, they become parented to the terrain. This means that the colliders are treated as part of the TerrainCollider. In turn, this means that if you character is touching the terrain, and then touches a tree, OnCollisionEnter will not fire, as it is already inside the TerrainCollider. I seem to remember hitting the same "gotcha" myself. You can verify this with a raycast into a tree, and printing off the collider object in a Debug.Log statement.

avatar image
0

Answer by getyour411 · Feb 26, 2014 at 09:31 AM

http://answers.unity3d.com/questions/650308/how-do-i-interact-with-terrain-trees.html

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

17 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 avatar image

Related Questions

Destroy Terrain Trees And They Collider 0 Answers

How can I make my truck drive on terrain and on bridge 1 Answer

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

My trees have their collider misplaced 0 Answers

Exporting Tree collision with heightmap 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