• 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 /
This question was closed Aug 29, 2015 at 10:58 AM by getyour411 for the following reason:

Problem is not reproducible or outdated

avatar image
Question by bloodyduskteam · Mar 17, 2013 at 11:52 AM · terraintreesterraindata

Why does my tree script not work

Hi , so I know another {one} about trees not using scripts because there not actual gameObjects....

So I ended up making a working cut the tree down script... but when I went to mass place the tree prefabs ... The script ended up nulling out that goes with the tag reverting back to default instead of " Tree ". So I looked threw the documentation and found terrainData and treeinstantce ... so I wrote a for loop and have a loading screen wait untill all the "Fake tree objects are created " meaning just the collider with a tree damage script " Java script "

The problem i'm having now is that .... ok it creates the number of trees for treeInstances so if I have 10 trees 10 fake tree objects with collider , if I have 20 ,... 20 fake tree objects suberb .... Ok there being made its loading , loading done.... HUH! the trees are all at 1 position on the corner of the terrain so I know I wrote the terrain positions array wrong and im not sure so much on how the positions are stored.... for the terrain data ...

Here is a snap shot of whats happening : alt text

Here is my script :

 //This script finds all the terrain's trees then creates the tree object for user interaction for each tree position
 
 var treeFab : Transform;
 
 var grabTerrain : Terrain;
 
 
 function Start () {
 
              
         for (i=0; i <Terrain.activeTerrain.terrainData.treeInstances.Length; i++)
         {
         
             //var treeInstances : TreeInstance = new Terrain.activeTerrain.terrainData.TreeInstance();
             
         
             
             Instantiate(treeFab, Terrain.activeTerrain.terrainData.treeInstances[i].position, Quaternion.identity);
         }
 
 
 }
 
 
Comment

People who like this

0 Show 0
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

0 Replies

  • Sort: 

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

10 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

Related Questions

How can I generate terrain trees at runtime? 1 Answer

Terrain trees or GameObjects? 0 Answers

Why does my tree script not work 2 Answers

Tree color variation with _TreeInstanceColor not working anymore? 2 Answers

Removing terrain tree at runtime not updating collider 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