Yesterday I was thinking about how to make a fun game about being a caterpillar, and came to the conclusion that the make or break would be in the trees. Toward that end I wrote an L-system tree generator in Unity3D. I’ve exposed a couple of variables so you can click on ‘em to change the rules that are being consulted to generate the tree. Give it a try!
Technical details
If you want the source code for this, you can grab it here.
In the process of making this experiment, I discovered a couple things: Establishing the parental hierarchy for objects in Unity3D by using <childNode>.transform.parent = <parentNode>.transform requires the additional re-zeroing of the localPosition, localEulerAngles and presumably localScale in order to take effect. The assignment of the transform’s parent also updates the local values to preserve the current world-space orientation and scale of the transform. I can see the argument for running things this way, but it wasn’t what I expected so it tripped me up for a while.
















































Very nice solution!
thank you.
Can you add a cannon to shoot off some branches?
Comment by gnoblin — December 31, 2010 @ 3:15 am
hey Brandel! thank you very much!!! really cool l-system-implementing!!
)
i took your code and added a little bit colors and stuff
http://ginger-and-lemon.ch/media/uploads/ba/growtest/WebPlayer.html
we’re working on different tests for our bachelor-game;))
keep it up!
livio
Comment by Livio — April 5, 2011 @ 12:01 pm