# Defold Crowd Native Extension

**URL:** <https://forum.defold.com/t/defold-crowd-native-extension/82994>\
**Category:** The Defoldmine\
**Created:** [July 7, 2026, 6:55am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994 "2026-07-07T06:55:02Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [July 7, 2026, 6:55am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/1 "2026-07-07T06:55:02Z")

</div>

![crowd1160](https://forum-defold-uploads.b-cdn.net/original/3X/7/b/7bb61040d9418e8714e23fd26df7acd9153318bc.jpeg)

Collision avoidance is a subject I try to tackle from time to time. I have tried [steering behaviors](https://x.com/selimanac/status/1857054672554442885) and custom solutions before. They all had their own pros and cons. Testing ORCA and RVO2 was always on my mind. Thanks to a push from @Alex_8BitSkull , I tumbled down the rabbit hole and somehow managed to come back 🙂

I used [RVO2](https://github.com/snape/RVO2) as a blueprint, but this solution was written from scratch. The only part I use is the ORCA solver, which is obviously based on the same algorithm.

There will be two versions available:

- **Standard** is free for personal, educational, experimental, and completely free, non monetized games or apps. The Standard version is coming in autumn 2026.
- **Pro** is available through paid access and requires at least a one time payment of $10 USD via GitHub Sponsors.

The Pro version is already available to all my past and current GitHub sponsors who have contributed at least $10. Special thanks for their support: @Alex_8BitSkull, @Pawel , Defold (team) and Refold (team), @AGulev

If you wanna check out the pro version → [GitHub Sponsors](https://github.com/sponsors/selimanac)

## So… what is this?

Defold Crowd is a native extension for local crowd avoidance in Defold. It helps many circular agents move through the same 2D space while avoiding each other and static obstacles.

You provide positions, radii, speeds, neighbor settings, and desired velocity. The extension computes avoidance velocities and updated positions for the next simulation step.

## What is it not?

Defold Crowd is not a complete movement AI system.

- No pathfinding. Plug in your own A\*, navmesh, waypoint graph, flow field, or route planner.
- No formations or group movement. Squads, offsets, ranks, selection logic, and coordinated movement belong in your game code.
- No universal arrival solution. Stopping, slowing down, snapping, attacking, queueing… They differ from game to game.
- No physical collision solver. ORCA computes avoidance velocities, but your game may still need placement rules or overlap correction.

## Extra features

- Polygonal and circular obstacles. Circular obstacles are cheaper than vertex based obstacles.
- Navigation masks. Air units do not collide with ground units, etc.
- Avoidance responsibility. Selected units yield more, or vice versa.
- Defold’s JobSystem and parallel simulation (Pro version only)

### Managed game objects

There is a managed game object solution, but it is basically a reference implementation, not a production system. The managed game object API demonstrates how the native side drives Defold transforms, including goals, preferred velocity, simulation steps, and position write back.

It intentionally covers only the simplest case: a single collection of agents moving toward fixed world space goals. It can be treated as a starting point and a code reference. For real projects, you will probably want to extend it or replace it with your own native C/C++ implementation.

## Technical features

The extension allocates during context setup and destruction; simulation steps use the memory reserved by the context.

- No C++ STL containers or strings.
- No classes; the core uses `struct` and `namespace`.
- No virtual functions.
- No exceptions or RTTI used by the source.
- No runtime allocation during simulation. Memory is reserved at context creation and released at destruction.
- Uses Defold allocation through `dmMemory::AlignedMalloc` / `dmMemory::AlignedFree`.
- Explicit types only; no `auto`.
- Small C/C++ standard headers only + Defold SDK headers.
- Error handling uses result enums instead of exceptions.
- Cache-conscious structs with `DM_ALIGNED(N)`: `Agent` is 64-byte aligned, `Obstacle` is 32-byte aligned.

## License Summary (not legally binding)

- ✅ **Standard** is free for personal, educational, experimental, and **completely free** non-monetized games or apps.
- 💲 **Pro** is paid-access only and requires **at least a one-time payment of $10 USD** via [GitHub Sponsors](https://github.com/sponsors/selimanac).
- 💲 Any monetized game/app using either version requires **at least a one-time payment of $10 USD** via [GitHub Sponsors](https://github.com/sponsors/selimanac).
- 📩 Free releases are welcome to share project info (name, genre, date, links).
- 🔒 The Software is **closed-source** ; source access may be granted **upon request**.

See [License](https://github.com/selimanac/defold-crowd/blob/main/LICENSE.md)

---

<div class="post-metadata">

**Author:** ![Insality](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/insality/32/39737_2.png) [@Insality](https://forum.defold.com/u/Insality)\
**Post date:** [July 7, 2026, 7:48am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/2 "2026-07-07T07:48:20Z")

</div>

Congratulations on the release! That looks amazing, great job

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [July 7, 2026, 7:50am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/3 "2026-07-07T07:50:45Z")

</div>

Thank you for sharing! This is awesome! 😍

---

<div class="post-metadata">

**Author:** ![Alex\_8BitSkull](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alex_8bitskull/32/5424_2.png) [@Alex\_8BitSkull](https://forum.defold.com/u/Alex_8BitSkull)\
**Post date:** [July 7, 2026, 8:19am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/4 "2026-07-07T08:19:05Z")

</div>

Thanks so much for your hard work! I am so excited to play with this in my next project 🤩

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [July 7, 2026, 9:06am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/5 "2026-07-07T09:06:48Z")

</div>

Thank you, @Insality and @Pawel. I really appreciate it!

> [@Alex\_8BitSkull](#):
>
> Thanks so much for your hard work! I am so excited to play with this in my next project 🤩

Ah! So the next hit is coming then 🙂

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [July 7, 2026, 9:31am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/6 "2026-07-07T09:31:02Z")

</div>

This is really, really cool. I’m imagining this is mainly for objects “on tracks”? So things like side on 2D objects with gravity, or cars with inertia, wouldn’t work easily?

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [July 7, 2026, 9:37am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/7 "2026-07-07T09:37:57Z")

</div>

> [@totebo](#):
>
> This is really, really cool. I’m imagining this is mainly for objects “on tracks”?

Thank you.  
Nope, not really, unless you use pathfinding, probably HPA\* and flow fields. I guess the logo might be misleading.

> [@totebo](#):
>
> So things like side on 2D objects with gravity, or cars with inertia, wouldn’t work easily?

Sorry, I’m not sure I understand this correctly. But I can say that there is no gravity or force involved, only velocities.

This video probably explains it better:

[![](https://img.youtube.com/vi/fGikLWjkE3A/maxresdefault.jpg "RTS Pathfinding Explained (and Why It Feels So Good When It Works)") ](https://www.youtube.com/watch?v=fGikLWjkE3A)

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [July 7, 2026, 9:57am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/8 "2026-07-07T09:57:35Z")

</div>

> [@selimanac](#):
>
> Nope, not really, unless you use pathfinding, probably HPA\* and flow fields. I guess the logo might be misleading.

The logo is great! When I said on tracks, I meant things that don’t slide or react physically.

> [@selimanac](#):
>
> there is no gravity or force involved, only velocities.

Yeah exactly.

Sorry, I got over-excited and though this could potentially be used in a racing game with drift, or a platform game, but quickly tempered my excitement! 🙂

Still super cool, it could work really well in a crowd simulation game.

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [July 7, 2026, 10:11am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/9 "2026-07-07T10:11:56Z")

</div>

> [@totebo](#):
>
> Sorry, I got over-excited and though this could potentially be used in a racing game with drift

I hadn’t thought about this use case, but it seems very possible and could be very creative.

> [@totebo](#):
>
> platform game

This could also be a very creative way to use it, if you’re willing to accept the challenges. It might become something like [Swarm](https://www.youtube.com/watch?v=lEaHt87OLtI), but in 2D (XY or XZ).

---

<div class="post-metadata">

**Author:** ![MasterMind](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mastermind/32/31839_2.png) [@MasterMind](https://forum.defold.com/u/MasterMind)\
**Post date:** [July 7, 2026, 1:53pm UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/10 "2026-07-07T13:53:21Z")

</div>

This is amazing, congrats! Can’t wait to try it out when I get a chance!

---

<div class="post-metadata">

**Author:** ![gianmichele](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/gianmichele/32/24028_2.png) [@gianmichele](https://forum.defold.com/u/gianmichele)\
**Post date:** [July 7, 2026, 9:49pm UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/11 "2026-07-07T21:49:15Z")

</div>

Well done!  
I can’t go into details but crowd sims are my daily job so for the sake of my sanity, I won’t look at this anytime soon 😅

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [July 8, 2026, 7:01am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/12 "2026-07-08T07:01:44Z")

</div>

😳 this is absolutely not an industry standard(robotics etc.) or AAA game tool/solution (perhaps just Godot level) It is meant to be fun to use, so…

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [July 8, 2026, 7:30am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/13 "2026-07-08T07:30:12Z")

</div>

Here is a video to see it in action!

[https://x.com/i/status/2074045785201676402](https://x.com/i/status/2074045785201676402)

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [July 8, 2026, 7:40am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/14 "2026-07-08T07:40:37Z")

</div>

I intentionally didn’t share this or any other tests/statistics/benchmarks. People love to see this kind of stuff with large numbers, but in reality, games have so many other things going on that those numbers are not realistic at all. You need many layers of complexity on top of everything.

I would suggest that everyone look closely at the profiler and make their decisions accordingly, rather than relying only on FPS.

I benchmark every step and every part of the solution, checking how many milliseconds each calculation takes and comparing it with RVO2. The final version is 1.5 times faster than the original RVO2 implementation. That is all I can say. The rest is pointless. You should run your own tests based on your target hardware.

Since you already shared it, here is the original one 🙂

[![](https://img.youtube.com/vi/aQgDaU0FZu4/maxresdefault.jpg "crowd c 1440") ](https://www.youtube.com/watch?v=aQgDaU0FZu4)

You can push it to the limits for stress testing 🙂

[https://x.com/selimanac/status/2068396098394239387](https://x.com/selimanac/status/2068396098394239387)

---

<div class="post-metadata">

**Author:** ![Mathias](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias/32/44015_2.png) [@Mathias](https://forum.defold.com/u/Mathias)\
**Post date:** [July 8, 2026, 4:05pm UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/15 "2026-07-08T16:05:44Z")

</div>

I am here just for the music

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [July 8, 2026, 6:45pm UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/16 "2026-07-08T18:45:04Z")

</div>

Sorry for whistleblowing! Great vid though. 🙂

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [July 9, 2026, 6:57am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/17 "2026-07-09T06:57:40Z")

</div>

> [@Mathias](#):
>
> I am here just for the music

🙂  
[https://pixabay.com/music/video-games-minecraft-roblox-fortnite-video-game-music-350760/](https://pixabay.com/music/video-games-minecraft-roblox-fortnite-video-game-music-350760/)

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [August 1, 2026, 7:22am UTC](https://forum.defold.com/t/defold-crowd-native-extension/82994/18 "2026-08-01T07:22:06Z")

</div>

New features have been added to the Pro version. These are not directly related to the crowd sim, but they provide useful queries and collision results.

### New spatial queries

#### crowd.query\_agents\_in\_radius()

Finds active agents within a radius of a position. Pure center-distance test; agent radius is not included.

 ![Screenshot 2026-08-01 at 10.08.56](https://forum-defold-uploads.b-cdn.net/original/3X/d/f/dfbbbeb638b67690ca6af1ebd88f5d0524d22cd9.png)

#### crowd.raycast\_agents()

Casts a ray from (start\_x, start\_y) to (end\_x, end\_y) against active agents.

 ![Screenshot 2026-08-01 at 10.09.34](https://forum-defold-uploads.b-cdn.net/original/3X/2/b/2b4ab809e5f8b88ab26d8b919c798da38f0c50d0.png)

#### crowd.query\_circle\_obstacles\_in\_radius()

Finds active circle obstacles within a radius of a position. Pure center-distance test; the obstacle’s own radius is not included.

 ![Screenshot 2026-08-01 at 10.09.13](https://forum-defold-uploads.b-cdn.net/original/3X/d/e/de841c665528cc3914285c7b71dcca2555f58903.jpeg)

#### crowd.query\_circle\_obstacles\_colliding()

Finds active circle obstacles overlapping a query circle centered at a position. True circle-vs-circle overlap test.

 ![Screenshot 2026-08-01 at 10.09.17](https://forum-defold-uploads.b-cdn.net/original/3X/8/b/8b021b26d045884b53f2580f25ecbd8ac48267c2.jpeg)

#### crowd.raycast\_circle\_obstacles()

Casts a finite segment from (start\_x, start\_y) to (end\_x, end\_y) against active circle obstacles.

 ![Screenshot 2026-08-01 at 10.08.36](https://forum-defold-uploads.b-cdn.net/original/3X/c/1/c1d75c4555920108f3551ea5c5d54e6efc415f52.jpeg)
