• 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 Jakub159 · Apr 27, 2015 at 07:32 PM · destroytree

Cant destroy trees placed by Terrain editor

Hello, i made a prefab from 3D model of tree which contains Capsule Collider. Then i placed large amounts of trees by Terrain Editor. And then i made script that if player send raycast hit to the tree, tree will be destroyed, but if player send raycast hit to the tree, whole terrain is destroyed.

I tested:

-gameObject.tag (it shows "Untagged", but the prefab has tag)

-gameObject.name (it shows "Terrain")

PS: Collisions works fine

Comment
Add comment · Show 11
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 fafase · Apr 27, 2015 at 07:36 PM 0
Share

I don't think terrain items are actual objects like the one you place in the scene. I assume they are part of the terrain itself as a whole mesh. So destroying a tree would actually means modifying the mesh, accessing the vertex list and finding the ones to put them down so that where they was a tree has become flat. Also, you would have to change the color data.

Well, my two cents on this, place the tree as an object, and destroy it like any others. Use some LOD system for performances.

avatar image Jakub159 · Apr 27, 2015 at 08:05 PM 0
Share

So how to fix it? Please, its quite tricky add every tree one by one

avatar image AlucardJay · Apr 27, 2015 at 08:48 PM 0
Share
  • http://answers.unity3d.com/questions/685405/mass-place-trees-tagging.html

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

avatar image Jakub159 · Apr 28, 2015 at 05:10 AM 0
Share

Thank you, mass place tagging looks good, but can you explain tree layers, how does it works? Plase, im new in unity.

avatar image AlucardJay · Apr 28, 2015 at 05:41 AM 0
Share

When the trees are applied using the terrain engine, they become part of the terrain, so tree colliders become one as part of the terrain (as stated by fafase).

I'm really not sure what you're referring to regarding 'tree layers'.

This whole mechanic you are wanting to implement is no easy task, especially for a new user. The simplest solution is (again as described by fafase) to use separate tree objects in your scene. You will still need to be aware of the collider limit, as well as LOD. Random mass placement can be done by code, or the current tree positions can be copied and used for placement as well.

The other problem with modifying the terrain collider at runtime (or any manipulation of a colliders vertex information) can cause the engine to noticibly 'lock-up' creating 'lag'.

If you want to continue the discussion, I am happy to in the forum section, but for now I think the best solution for a new user has been suggested, use separate tree objects. This tutorial comes to $$anonymous$$d, maybe it can be of some help : https://www.youtube.com/watch?v=ZSbdzZVQWnI

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

Tree Destroy Help 2 Answers

RTS game Any help about Hide mesh or destroy trees Terrain? 1 Answer

Deleting Terrain Trees Dynamically 1 Answer

Remove trees dynamically - stuck with collider 3 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