Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 3kWikiGames · Jul 31, 2018 at 06:36 PM · rotationprefabstreesterrain-trees

All terrain trees face the same way?

So as you can see in my example all of the trees that I have are facing one direction which id like to be able to change the rotation so that it will seem more natural, any way of doing this instead of having to create seperate prefabs with different rotations for each tree? Thanks!alt text

screenshot-37.png (457.1 kB)
Comment
Add comment · Show 5
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 madks13 · Aug 02, 2018 at 08:51 AM 0
Share

How are you placing your trees?

avatar image 3kWikiGames madks13 · Aug 03, 2018 at 04:44 AM 0
Share

I'm placing it using the terrain, paint trees method.

avatar image madks13 3kWikiGames · Aug 03, 2018 at 08:17 AM 0
Share

Ok. Sorry but i haven't used that tool yet, and unfortunately i don't have time to experiment with it to give you an answer. I hope someone with more knowledge answers this.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by remy_rm · Aug 03, 2018 at 02:32 PM

If your underground is of type terrain you can add your trees to the tree painter and use the mass place trees function with random rotation checked.

Alternatively you can make an editor script that searches for all the trees in your current scene and applies a random rotation to it when you click "rotate" in the newly added "Trees" menu:

  [MenuItem("Trees/rotate")]
     public static void RotateTrees()
     {
         foreach (<T> tree in FindObjectsOfType<T>())
         {
             //for every found tree get the transform fo the gameobject and set its Y rotation to a 
             //random value beween 0 and 360 degrees (up to 2 decimals)
             tree.gameObject.transform.localEulerAngles = new Vector3(0, Random.Range(0f, 360f), 0);
         }
     }

where in FindObjectsOfType has to be replaced by a component only your tree has (maybe a script called tree or something). Alternatively you can also search by name or tag, whatever floats your boat

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 Feuerputz · Jul 08, 2020 at 12:09 PM 0
Share

Hey cool script, but it does work for gameobjects only. Do you have an idea how to do this with the trees which are placed on the terrain?

avatar image Retrochamber · Dec 15, 2020 at 05:19 PM 0
Share

In the TerrainData files you have a property TreeInstances.

https://docs.unity3d.com/ScriptReference/TerrainData-treeInstances.html

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

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

Related Questions

Rotating a Prefab? 3 Answers

Can terrain trees run their own script? 1 Answer

SpeedTree Trees Extremely High Draw Call Count? 3 Answers

Why is my person walking through trees? 1 Answer

How do you make objects solid? 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