Search Unity

Scripts to trees???

Discussion in 'Scripting' started by EnsurdFrndship, Jul 26, 2014.

  1. EnsurdFrndship

    EnsurdFrndship

    Joined:
    Apr 17, 2010
    Posts:
    786
    Hello,
    I was wondering if there is a way to create tree objects for terrains with scripts attached to the trees so that the trees can behave a certain way. Thank you for any information.

    Sincerely,
    Michael S. Lowe
     
  2. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    Place a tree in the scene.
    Add the script you wish to the tree.
    Create a new prefab and name it as you wish.
    Drag the tree from the scene (with the script) to the prefab.
    Now put that prefab in the Tree section of Terrain and try.
    I hope it works :)
     
  3. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  4. ensiferum888

    ensiferum888

    Joined:
    May 11, 2013
    Posts:
    317
    Scripts on your tree prefabs will not work using the terrain system. I'm pretty sure the whole terrain draws the tree meshes using Graphics.DrawMesh() it's not an actual object so any scripts you put on them won't be called by the engine.