tnSuperman tanktn oParticles uExtrusion j3d sandy flExtrusion fuelyoursenses meshCam bufferSnake dMap2 dMap pv2 cursorFire opticks faceGame FPSnake pv preOpticks painty youtuber fractalFIngers 2dbals

December 30, 2010

L-system in Unity3D, with Source

Filed under: Games,unity — Tags: , , , , , , , , — Brandel Zachernuk @ 2:24 pm

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.

Older Posts »

Powered by WordPress