The Hive - Procedural Boundary and Self-Collision Avoidance in Geometry Nodes
Overview
This package provides a modular suite of Geometry Nodes setups demonstrating autonomous swarm agent navigation, obstacle raycasting, and neighbor collision avoidance inside a Simulation Zone. In addition to the main production file, separate step-by-step blend files isolate each core mechanic:
-
Step 1 — Random Direction Movement (Separate File): Initializes points with a stored heading attribute and advances position per frame using
Vector RotateandSet Position. - Step 2 — Stepped Random Steering (Separate File): Implements per-agent decision timers using floored frame division and dual boolean coin flip to alternate between straight movement and smooth left/right arcs.
-
Step 3 — Boundary Raycast & Forward-Scan Collision: Adds look-ahead raycasting against obstacle meshes and a forward-cone neighbor check (
Dot Product > 0) with a configurable distance threshold. -
Step 4 — Boundary Raycast & 360° Proximity Scan: Implements full radial neighbor detection using
Index of Nearestand 2D cross-product sign evaluation to steer left or right away from adjacent agents.
Depending on the file, trees utilize either Simultaneous Origin Spawning (to isolate radial dispersal and steering math) or Time-Gated Frame-by-Frame Spawning (the primary method for continuous, non-overlapping swarm emission).
Geometry Nodes Setup & Controls
- 1. Spawning & Nest Emitter (
1. Dynamic Nest Emitter):-
Spawn Interval (
Modulonode): Controls emission cadence usingScene Time [Frame] mod N == 0(default:6frames). Ensures each agent steps clear of the nest before the next point is injected viaJoin Geometry. -
Max Population Cap (
Compare: Less Than): EvaluatesDomain Size [Point Count] < Max Ants(default:50) and combines with the timing gate via a booleanANDnode to halt emission at capacity. -
Nest Position (
Set Position): Defines the(X, Y, Z)origin coordinates for newly emitted points.
-
Spawn Interval (
- 2. Stepped Random Steering (
2. Random Steering):-
Decision Window (
Min / Max Frames Before Turn): Maps a per-index random float to a frame interval (default:[15, 60]frames). -
Stepped Epoch Seed (
Floor(Frame / Interval)): Freezes the random seed across each agent's interval window so steering angles accumulate smoothly instead of jittering every frame. -
Turn Probability & Rate (
Random Value [Boolean]&Switch): Two independent boolean nodes (decorrelated viaID = Index * 2) select between walking straight (0.0 rad) or curving left/right (±0.045 rad/frame).
-
Decision Window (
- 3. Self-Collision Avoidance (
3. Self-Collision):-
Personal Space Threshold (
Compare: Less Than): Compares distance to the nearest neighbor (Index of Nearest→Sample Index) against a customizable radius (default:2.5m–4.0m). -
Forward-Scan Mode (
Dot Product > 0): Filters neighbor detections to the forward 180° hemisphere by dotting the agent's forward heading vector with the neighbor offset vector (P_neighbor - P_self), applying a snappy evasive turn only when obstructed ahead. -
360° Scan Mode (
Cross Product Z-Sign): EvaluatesCross(Forward, ToNeighbor).z > 0to determine whether a nearby neighbor lies to the left or right, steering away bya value.
-
Personal Space Threshold (
- 4. Boundary & Obstacle Raycast (
4. Boundary Raycast Collision):-
Collision Target (
Object Info: THE COLLISION OBJECT): References the obstacle object walls and obstacle geometry inRelativespace. -
Detection Distance (
Compare: Less Than): ChecksIs Hit AND Hit Distance < 10.0malong the agent's current forward vector (Ray Length = 50.0m) and adds a rebound angle tosaved rotation attribute..
-
Collision Target (
- 5. Movement & Instancing (
5. Move Forward&6. Instance Ant):-
Speed (
Vector Math: Scale): Multiplies the normalized forward heading vector by the step distance per frame (default:1.0). -
Instance Alignment (
Instance on Points): Reads the updatedrotation attribute outside the Simulation Zone, converts it, and aligns the target mesh specified.
-
Speed (
Discover more products like this
nodes ant simulation collision detection flock procedural swarm collision avoidance boids ant collision boids in geometry nodes geometry nodes