I decided to use Unity engine, because it’s the game engine I’m the most comfortable working with. First I started to work on a plant system. I want the player to be able to plant plants and watch them grow in fast motion.
To create plants, I decided to generate the plant meshes procedurally in order to generate plants based on the surroundings.
The plants are constructed with multiple cylinders with varying width and position.
I then wrote some code to procedurally generate this mesh, starting with a single segment.
Animation & Noise
I wanted to make the plant grow fast in front of the player. To do this, animating the meshes was the next step. One essential component is also noise, to make the plant diverse and procedural. The noise I used is a 3D Perlin noise.
- Radial noise (for the variation in the with of the trunk)
- Noise influence across the length of the stem
- Noise in the growth animation before reaching the final girth
These noises are controlled across the length of the stem and also across time.
The way I constructed the segments permitted me to easily animate the width of the segment with some noise.
The next step was putting these cylinders back to back to create growing stems. I tried to make all the parameters accessible to have a maximum of control on the way meshes are created. Only my imagination is the limit!
I wanted to make plants grow in the environnement and be completely procedural so the next step was making the plants collide with the surroundings.
I used Unity raycasts to calculate collision all at once when the mesh is created. After a lot of trial and error, I finally managed to make this work!
I then experiment with very thin, spaghetti-like plants, that would look like cables roaming through the white default sandbox.
Another really important component is the influence of gravity along the plant. This value can be controlled along the stem, to have a plant go upwards (for trees for example), or be close to the ground, like vines or roots.
Combining all these elements, we can get visuals like this: