Zachernuk

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.

2 Comments

  1. Very nice solution!
    thank you.

    Can you add a cannon to shoot off some branches? ;)

    Comment by gnoblin — December 31, 2010 @ 3:15 am

  2. 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

RSS feed for comments on this post. TrackBack URL

Sorry, the comment form is closed at this time.

Powered by WordPress