Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Spawning Trees and Boulders on Texture2d

Discussion in 'Scripting' started by Josenifftodd, Mar 31, 2016.

  1. Josenifftodd

    Josenifftodd

    Joined:
    Nov 29, 2013
    Posts:
    158
    Anyone want to explain how I do this? my planet generates out with different textures around, would I spawn my trees and boulders on the vertices? I seen a tutorial on doing pools on youtube but I'm not sure how I'd make it so they spawn on locations, so I want trees/grass to be on my ground texture, boulders and rocks on mountain texture.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    Definitely want to go back to here (Learn) and take a look at a few of the tutorials to see how this sort of thing is commonly done.
     
  3. Josenifftodd

    Josenifftodd

    Joined:
    Nov 29, 2013
    Posts:
    158
    Wouldn't I just use the texture height of my terrain? to spawn trees out and about and then use identity for the rotation?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    If your terrain is 2D sideview (like one giant sprite) then you need to write code to find the pixel edges of the ground going across. Or you can put custom polygon colliders on them and use that to test.

    If instead your texture is a 2D heightmap representation of a Unity3D terrain object (for a 3D game), then it is a completely different problem to find the height at a given point.