Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Jul 2010
    Posts
    472

    Mass-Placed Trees... Scripted?

    Hey all,

    Recently I picked Unity back up with the goal of actually learning it this time around. Came back to the best place I've ever been to learn most of what I know and like always, have learned quite a bit about how Unity works... and have even broken the camera system up a bit so movement, gravity, and animations and such can be applied to other critters besides just the TPC-driven critter.

    Hoooowever, during one of my 'off' experiments, I found another place that explained how to trigger scripts based on hovering, leaving, and clicking objects in the world. So, I wrote a super-short script that basically just informs me when any of those three things happen.

    If I drop a tree down and give it a collider and throw a script on it, it works flawlessly 100% of the time. If, on the other hand, I create a prefab with that collider and script and then try to mass-place (Or paint) trees down and then try it, it fails 100% of the time.

    It'd be nice, for example, to be able to place a bunch of trees in the editor and then chop them down. Is there a way I can make the scripts work when painting the trees onto terrain?

    Thanks!
    "It's most impressive when it's least expected."

  2. #2
    Join Date
    Feb 2014
    Posts
    277
    It's been a while since I played with lots-of-trees-at-once but I do recall they weren't placed like objects. To save time loading huge terrains I think they were itemized in a single file - sort of semi-static.
    I had the idea of a lumberjack profession being able to visibly change the tree to a stump for 20 minutes. So I thought to edit this file with a script just like the tree painting tools did it. I recall that the method calls weren't actually clearly mentioned in the documentation. It was about then that I decided to really get into c# and leave Unity for another day so I never got to try it out. Times change and I bet things are different now. Probably this post is too vague or simply wrong since the 4.4 days.

  3. #3
    Join Date
    Jul 2010
    Posts
    472
    It seems to still hold pretty true. Last night I decided "Well, maybe if I made the tree a child of the prefab instead of the prefab itself..." and made it a child of the prefab. By making it a child of the prefab, I actually managed to make all the trees (Of that prefab) completely disappear. Meaning, it seems that ONLY the prefab gets painted. Any children of the prefab are ignored. I suspect that holds true for most components on the prefab itself. I do kind of wonder if there's a way to go into the Terrain Toolkit's scripts itself and tell it "By the way, you need to pay attention to children and scripts. Or at the very least, scripts."

    Last night I did some terrain adjustment (Something I haven't done since I painted the trees) and discovered that the toolkit-placed trees actually conformed to the terrain....... that's a seriously helpful feature, but it's also useless if I can't use those trees practically alongside cosmetically.
    "It's most impressive when it's least expected."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •