Jump to content

Howto: access individual trees? - [solved]

Go to solution Solved by Peter,

Recommended Posts


by default, trees can not be accessed individually, like an object where i could change the
position. Is there a way to access individual trees, other than spawning them as a GameObject?

What this questions refers to: my question may originate from that i dont understand how to
access (either in editor or via C# code) the spawned trees. This may be needed when running
a strict authoritative server.

Example where this would be needed: in scenarios where an explosion shall remove trees/objects.
(also needed for for grass, but this probably works different than trees- would still like to know).

Thanks and cheers.

Link to comment
Share on other sites

Hey there, yes you can do this via biome spawners. 

They are set by default to terrain trees due to the performance impact of having 100's of trees as game objects. 
If you wanted to change this all you need to do is go to the tree in question or even creating your own tree spawner. 
Open the resource settings and change the resource type to game object: 

  • Thanks 1
Link to comment
Share on other sites

Hi Bryan,

thank you for looking into my question! Before i mark this as solved;

Isn't there any 'map' or 'matrix' that holds the coordinates of each tree (placed as tree, not Game
Object)? If yes, couldn't this be accessed programmatically? Maybe that question is leaving the
scope of Gaia, but incase you guys have wrote your own implementation of tree placement and
not using that of unity's terrain painter, then i'd might have a chance that such map/matrix exists.

As you already stated, having hundreds of GameObjects would heavily impact performance.
If we could access 'terrain painted' trees (not GameObjects) with C# scripts, that may solve this.
Or do you know of other methods that exist? I just wonder how games handle this problem, like
i.e. "Rust" (also built with unity) that has large open worlds.

Thank you!

Link to comment
Share on other sites

  • Solution
1 hour ago, Haxel0rd said:

Isn't there any 'map' or 'matrix' that holds the coordinates of each tree (placed as tree, not Game

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

Every Terrain object has a terrain.terrainData, in there you can get all tree instances. I would recommend to look over the API manual pages for both the terrain and the terrain data object to get a feeling what is in there and what not, you might find more useful stuff in there.

  • Thanks 1
Link to comment
Share on other sites

  • Haxel0rd changed the title to Howto: access individual trees? - [solved]

Hi Peter,

thank you for the info, in combination to Bryans answer, this perfectly answers my question!
Thank you guys!

Marked as solved, Cheers.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

  • Create New...