Simulating Bugs Crawling on Objects
local graph
Chapter 19 — Simulating Bugs Crawling on Objects
Section titled “Chapter 19 — Simulating Bugs Crawling on Objects”In the previous chapter, we learned how to utilize the Bake node to save sequences of our node tree. In this chapter, we’ll learn how to create crawling bugs in the Geometry Node editor.
The techniques covered here are highly relevant for any procedural artist. The overall goal of this chapter is to build a versatile, fully procedural system that simulates bug-like creatures crawling across the surface of any mesh, giving you a deep understanding of how to build stateful animations from the ground up.
We will start by adding a node tree on a mesh object for our bugs to crawl on. After that, we’ll distribute some points over this surface.
We’ll also make the points move by making use of a Noise Texture node. After this, we’ll make sure the points stick to the surface, and we’ll give the points a tail.
Lastly, we’ll make the tail move randomly by the use of another Noise Texture node.
Figure 19.1 shows the final result we’ll be aiming to create by the end of this chapter:

Figure 19.1: End result of this chapter
These are the topics we will be covering in this chapter:
- Setting up the scene
- Moving points over the surface
- Adding a tail to the points
- Finishing up the scene
By the end of the chapter, you’ll be comfortable with tackling complex Simulation Zone challenges in the range of procedural details. This includes layering procedural noise for both the bug’s movement as well as the tail of the bug.
Without further ado, let’s get right into this exercise!
Technical requirements
Section titled “Technical requirements”Some figures in this chapter show the full Blender setup, including node trees, outcomes, and parameter settings. For easier viewing and readability, these figures are also available in the book’s GitHub repository
You can find the exercise from this chapter in the common .blend file in the book’s GitHub repository.
Setting up the scene
Section titled “Setting up the scene”Let’s start off this exercise by following these steps to set up our scene:
- Add an Icosphere object to our Viewport. Let’s give it a Subdivisions count of
4and a Radius value of3meters. Let’s also Shade Smooth our object. - Next, we’ll head to the Geometry Node editor and add a geometry node tree to this Icosphere object.
- We want to start off by instancing some points. To do that, let’s use a Distribute Points on Faces node. Drop it between the Group Input and Group Output nodes.
We’ll see a bunch of points appear, but it is way too much. Let’s turn our Density value down to 2.
- We also want to keep seeing our original Icosphere object, so let’s add a Join Geometry node at the end of our node tree and connect our original mesh to it.
Now that we have our points visible along with our Icosphere object, it’s time to start procedurally moving these points over our surface!
Moving points over the surface
Section titled “Moving points over the surface”It’s now time to make our points move. To get started, follow these steps:
- Let’s add a Simulation Zone between the Distribute Points on Faces node and the Join Geometry node.
- Following that, drop in a Set Position node in our Simulation Zone. This node will be responsible for modifying the position of our points each frame.
Nothing will happen yet because we haven’t given any input to our Set Position node yet.
- As our input, let’s use Noise Texture set to 4D with a Scale value of
0.1and a Detail value of0. - Connect the Color output of the Noise Texture node to the Offset input of the Set Position node.
- When we hit play, we can see that our points fly away. This is because we didn’t subtract our Noise Texture value by
0.5yet. - To do that, let’s add a Vector Math node set to Subtract with a value of
0.5and drop it between the Noise Texture node and the Set Position node.
If you have followed these steps correctly, this is what your current node tree should look like:

Figure 19.2: Your current node tree
If we hit play now, we can see that our points will fly in all directions equally. This is supposed to happen because our next step is making the points stick to our surface, which we’ll explore in the next section.
Making the points stick to the surface
Section titled “Making the points stick to the surface”If you don’t know how to tackle this problem, this might feel like a challenge. But don’t worry, we’ll explain the process step by step:
- Let’s start by adding another Set Position node after our first Set Position node. This node will be responsible for sticking the points to the surface by searching for the nearest surface point.
- To do this, we can make use of a Geometry Proximity node. To set this node up, let’s branch off our original geometry by using a Reroute connection, which you can make using Shift + right-click + drag over our original Geometry line.
Let’s place our Geometry Proximity node as follows:

Figure 19.3: Geometry Proximity node
- As you can see in Figure 19.3, let’s also connect the Position output of our Geometry Proximity node into the Position input of our Set Position node. This will cause all points to be snapped to the nearest face on our target surface!
- When we hit play, we can see that the points snap to the surface nicely. Although we can see that all the points gather at a single location, this is not what we want. We can fix this issue by modifying the W value of our Noise Texture.
For that, we want to use a specific formula that will give each point a separate animated W value.
This formula is (Frame/10) + random(0;10000). We can’t enter this straight into our node tree, of course, so let’s convert this to nodes as seen in Figure 19.4:

Figure 19.4: Formula converted to nodes
- Go ahead and build this node tree. Once you hit play, you’ll see that all our points are crawling along our surface nicely and evenly.
- Let’s select all the nodes we’ve just added, along with the Noise Texture node and the Vector Math node, and combine them into a frame by executing Shift + P.
- Let’s name the frame
Calculating Random Movementand give it a different color.
In the next section, we’ll add tails to our points.
Adding a tail to the points
Section titled “Adding a tail to the points”Let’s add a tail to our points! This is a nice addition to our current project to add detail and a dynamic feel to our bugs.
To add tails to our points, we will have to instance a curve line on each of our points. To do this, start by adding an Instance on Points node after the Simulation End node. Let’s also connect our Simulation End output into the Join Geometry node as well so we can see our points again.
For the instance input, we’ll choose a Curve Line node. Once we connect this node, we can see that a bunch of lines appear on our Icosphere object.
To align the lines in the direction the points, or bugs, are moving, we will need to perform some calculations. We’ll walk through those calculations in the subsequent section.
Calculating the direction vector
Section titled “Calculating the direction vector”We can obtain the vector of where a point is going by saving the original position vector and subtracting it from the current position vector, as mathematically demonstrated in Figure 19.5:

Figure 19.5: Mathematical explanation of direction vectors
Let’s apply this theory to our tail position, where Coordinate 1 is our original position vector and Coordinate 2 is our current position vector. Keep in mind that in our case, we will be working with three values instead of two because our scene is three-dimensional.
To obtain our original position vector, we will need to save it before we modify the position. We can do this using Store Named Attribute set to Vector. Drop this node right after our Simulation Begin node. Let’s name this attribute originalposition.
Currently, we’re not giving any input to this node other than our geometry. To fix that, let’s add a Position node to input the position data into our Store Named Attribute node. Plug the Position node into the Value socket of the Store Named Attribute node.
Now that we have that value saved, it’s time to make use of the mathematics provided in Figure 19.5.
To do that, we’ll use a Vector Math node to subtract our Original Position Named Attribute from our current Position, which we can do using the nodes seen in Figure 19.6:

Figure 19.6: Obtain the direction vector using Position data
Once we’ve got this set of nodes built out, it’s time to convert this Vector value into Rotation data for our Instance on Points node.
We can make this conversion by using an Align Rotation to Vector node, which we have previously used for aligning the bricks to a Curve object in our Procedural Wall exercise in Chapter 11. Let’s drop this node in after our Vector Math node and set it to Z and auto, which should be the default settings.
By default, Blender will connect this node to the Rotation input, which is not correct; we need to connect it to the Vector input instead.
Once you have switched the input from Rotation to Vector, it’s time to connect the Align Rotation to Vector node to the Instance on Points node’s Rotation value, as seen in Figure 19.7:

Figure 19.7: Connecting the node to the Instance on Points node
Let’s also select these nodes into a frame using Shift + P and name the frame Direction Vector Calculation. Let’s also give it a different color.
If you now play your animation, you’ll see that the tail now follows your point!
Our tail now consists of a curve, which has no thickness. We want to add thickness to this curve using a Curve to Mesh node. We’ll focus on this in the next section.
Adding thickness to the tail
Section titled “Adding thickness to the tail”To begin this challenge, follow these steps:
- Start by adding a Curve to Mesh node after our Instance on Points node to convert our tail into a mesh. We’ll use a Curve Circle node as the Profile Curve input.
- Once you have done that, we can add some variable thickness to this curve by utilizing the Scale input on the Curve to Mesh node.
- We want our tail to start thick near the body, or point, and end thin. We can achieve that by utilizing a Spline Parameter node’s Factor output. Connect this output to the Scale input of the Curve to Mesh node.
As you can see in Figure 19.8, the thickness profile of our tails is inverted, which is not the desired result:

Figure 19.8: Tails thickness is inverted
We can flip this around by utilizing a Float Curve node, which remaps values from 0 to 1.
- Let’s drop the Float Curve node between the Spline Parameter node and the Curve to Mesh node.
- Use the following curve for our Float Curve node. This will ensure our tail gets nicely rounded at the end.

Figure 19.9: Float Curve profile
We start to notice an issue, though – our tail isn’t sticking onto the surface everywhere. Let’s fix that.
Sticking the tail to the surface
Section titled “Sticking the tail to the surface”Just like we made the points stick to the surface earlier in the chapter, we want to stick the tail to our original geometry. This is necessary because otherwise the tail will float in the air when it comes upon a steep corner.
Follow these steps to begin the process:
- To get started, we want to add more resolution to our tail. For this, we’ll need to add a Resample Curve node right after our Curve Line node. Let’s keep the Count value at
10. - To make the tail stick to the surface, we’ll add another Set Position node right after our Instance on Points node. We can take the Position vector of our previously added Geometry Proximity node and drag it all the way to the Position input of the Set Position node that we have just added.
- Once you plug this node connection in, you will see that nothing happens. This is because our curves are still an instance, and instances can’t be modified using a Set Position node.
- To fix this, let’s add a Realize Instances node right before our Set Position node.
Once you do this, you’ll see that the tails snap to the surface, as you can see in Figure 19.10:

Figure 19.10: Tails snap to the surface
Although the tail now sticks to the surface, it looks a bit dead. To fix this, we can add movement to the tails by making use of another Noise Texture node.
Making the tail move
Section titled “Making the tail move”Follow these steps to add randomized movement to the tail geometry:
- Add in another Set Position node right after the Realize Instances node.
- Just like before, let’s use a Noise Texture node along with a Vector Math node set to Subtract with a value of
0.5, and connect it to the Offset input of the Set Position node. - Then, we’ll set the Noise Texture node to 4D mode and give it a Scale value of
1.5with a Detail value of0. This will give the tail a calm and randomized movement to the tail. - Let’s also enter
#frame/10in the W value to gradually change the noise pattern of the tail. - When you restart your timeline using Shift + Left Arrow and play your animation, you’ll see that the heads of some of the bugs are detached from their tail.
This is because we are modifying the position near the head using our Noise Texture node. We can fix this by multiplying our noise vector by the Spline Parameter Factor value, which means it will be multiplied by 0 near the head of our bug.
- To do this, let’s add in another Vector Math node set to Multiply and drop it after the first Vector Math node.
- Additionally, locate our previous Spline Parameter and drag the Factor output right into the second Vector input of the Vector Math Multiply node.
This is what that part of the node tree should look like, as shown in Figure 19.11:

Figure 19.11 – Multiply Noise Texture by Spline Parameter Factor
If you now restart your timeline and play your animation, you’ll see that the tails are now correctly connected to the points.
Let’s select the nodes we’ve just added and group them into a frame by executing Shift + P. Let’s name the frame Tail Random Movement and give it a different color.
Finishing up the scene
Section titled “Finishing up the scene”We are not done, though; we still need to perform some minor operations to finish our scene.
For example, right now we are using a point as the head of our bug. This will not be visible when rendering out our scene. To fix this, we will need to instance an Icosphere where the points are. Let’s walk through the steps to do this:
- Right where our Simulation Zone ends, we branch our geometry line into two parts: one of these parts is the tail, and the other part is the points. We’ll drop an Instance on Points node on the empty line, where our points are.
- Let’s give the Instance on Points node a Scale value of
0.1on all axes, so our instanced objects aren’t too big. - As an instance, let’s use an Ico Sphere node with a Radius value of
0.75and a Subdivision count of3and connect it to the Instance on Points node’s Instance input. - We can see that the Icosphere looks kind of blocky, though. To fix this, let’s drop in a Set Shade Smooth node after our Instance on Points node, which will smooth out the faces.
- It’s also interesting to connect the Direction Vector Calculation output to our Rotation input as well. It will not matter for now because our head is round and rotation isn’t visible, but this is handy if you want to change the shape of the head to a cube, for example.
Let’s select the nodes we’ve just added and group them into a frame by executing Shift + P. Let’s name the frame Head Icosphere and give it a different color.
Now that our node tree is almost done, it’s time to make our node tree easily accessible by adding Group Input.
Adding group inputs
Section titled “Adding group inputs”Let’s add some group inputs to our node tree. To get started, let’s add the inputs we’ll need in the Group Input node.
Select the node and press N to open the right-hand panel of the Geometry Node editor. Navigate to the tab called Group and add the following inputs there:
- Tail:
- Type: Boolean
- Default: True
- Comment: This toggle is used to turn the tail on or off
- Type: Boolean
- Density:
- Type: Float
- Default:
2
- Default:
- Type: Float
- Tail Length:
- Type: Float
- Default:
1
- Default:
- Type: Float
- Bug Speed:
- Type: Float
- Default:
1
- Default:
- Type: Float
- Tail Movement Scale:
- Type: Float
- Default:
1
- Default:
- Type: Float
Now it’s your turn! Try to incorporate the group inputs as well as you can. Do not forget to give values to these group inputs in the Modifier stack; otherwise, some values will be set to 0, and your node tree will not work.
Figure 19.12 shows the entire node tree of this exercise, along with the answers to the Group Input addition:

Figure 19.12: Complete node tree
That brings you to the end of this chapter!

Summary
Section titled “Summary”The chapter initiated the creation of animated, surface-crawling bugs by establishing a geometry node tree on a mesh object, laying the foundation for their movement.
Subsequently, points were distributed across the mesh’s surface and animated using a Noise Texture node, introducing dynamic motion.
To ensure realistic interaction, these points were then constrained to the surface, preventing them from floating. Furthermore, a trailing tail was added to each point, with its direction and movement intricately controlled by another Noise Texture, adding a layer of organic randomness.
The tail’s thickness was adjusted, and it was also constrained to the surface, maintaining visual consistency. Finally, the chapter concluded with scene refinement, focusing on adding group inputs to enhance user control and flexibility, thus completing the bug animation setup.
In the next chapter, you’ll learn how we can use the Simulation Zone and Repeat Zone to create a shrinkwrapping simulation!