Search Unity

Procedural placement? please help.

Discussion in 'Scripting' started by CED-stu, May 30, 2016.

  1. CED-stu

    CED-stu

    Joined:
    Mar 17, 2014
    Posts:
    5
    Alright, So let's get right down to the point, I have been at this for several hours programming with only bad results. and I have done lots of searching for this, only to no avail. I need a way to Procedurally place Trees, plants, and etc. in the Terrain(I make my own rather than use Unity's, I will never use Unity's). I would prefer the Language to be C# as I have great understanding of it, but what I need is for the trees to drop down to the terrain, not overlap each other too much(like have two conjoined trunks) and if you want to go as far as direct me how to make cities with roads that connect that will help, what I want though is something, even just snippets of code to help, so that I can generate Forests, Fields, towns that connect with roads etc. The Basic Idea overall is to have a program place down Grid Segments or really large cubes/rectangles that will be a location for Forests/towns/cities/Fields/etc. I am using my own Assets and Terrain. I do know a lot of C# but I cannot complete this without help, as none of my friends can understand programming(they think I'm some sort of wizard when it comes to computers)

    TL;DR: Please help in directing me how to place objects of which I made on the terrain that I have created, and possibly even generate towns.

    -Laikos CED.stu

    EDIT: Forgot to mention... Can we have rotation for trees&Etc. too... I don't wanna do that myself, Nor do I have money for the Asset Store for procedural placement etc.
     
    Last edited: May 31, 2016
  2. mumbot

    mumbot

    Joined:
    Oct 19, 2012
    Posts:
    86
    Hello. Currently im on my phone so I can not help you to much. But you can get the vertices on your terrain and place your trees randomly on those points. When i get home ill give you an example. But you will need to make some changes to the code as my code generates an entire planet with trees and rocks.
     
  3. vikankraft

    vikankraft

    Joined:
    Feb 25, 2016
    Posts:
    88
    He wanted to place them procedurally not randomly. I recomend a noise function to place them or even a simple Sine function curve just to start somewhere.
     
  4. mumbot

    mumbot

    Joined:
    Oct 19, 2012
    Posts:
    86
    Ah yes I miss read.
     
  5. vikankraft

    vikankraft

    Joined:
    Feb 25, 2016
    Posts:
    88
    I guess random would give a passable result in a more easily implemented way though ;)
     
  6. CED-stu

    CED-stu

    Joined:
    Mar 17, 2014
    Posts:
    5
    Random or Procedural would be great, personally I think random would be better, Ill give it a try when you respond to help, Ill perhaps use both if I can see an Example, would the vertices also work with Low Poly? just wondering because I usually use low Poly. -Laikos CED.stu
     
    Last edited: May 31, 2016
  7. image28

    image28

    Joined:
    Jul 17, 2013
    Posts:
    457
    Can't share the code ( previous employer owns it ). But I used image colour maps to define areas to place different types of objects. It would randomly select a from a list of prefabs for each object/colour type. And allowed for even spacing or random spacing and handled rotating to the terrain.

    Look in awe at my paint skills for an example

     
  8. CED-stu

    CED-stu

    Joined:
    Mar 17, 2014
    Posts:
    5
    Thank you everyone for the help so far.
    Sorry, its been quite a while since posting. But is there a name to this process? I've attempted some research but to no avail. If I could find a name I would be able to learn how to do this.
     
  9. image28

    image28

    Joined:
    Jul 17, 2013
    Posts:
    457
    At work right now, but I'll try remember to jump online after work sometime and walk you through it
     
  10. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924