Instancing geometry for animations?

Hello, I know that there is a TCastleTransformReference object for holding reference to model, where I can perform transformations. But for animation I have found out they need to be separate TCastleScene instances? Isnt there anything like sort of some instancing where we could play animations on object without need to copy its whole memory structure? Because those are heavy if you want to have lets say for example few tens or hundreds of animated people. Thanks.

It is indeed a problem, just as you describe – a use-case when you want to animate a crowd of people/animals/creatures and they all have to be a in a different animation state.

We don’t have a solution for it yet, though. Because of how our animations change the nodes graph, it’s not trivial. But it is planned, see roadmap point " 27. Allow animating selected node graph properties, without changing the graph, to be able to reuse graphs": Roadmap | Manual | Castle Game Engine . When this roadmap point is done, using it will be trivial – the instancing will happen automatically if you just have multiple TCastleScene with the same URL and all have Cache=true. So you can prepare your code / designs already for this… and once we implement it, it will just magically make memory usage of your applications much better.

For now, the only solutions are kind of “manual hacks”. That is, instead of having each person in crowd have a different animation, you can instead created use “batches”, e.g. make 100 humans use the same TCastleTransformReference and start “walk” immediately, next 100 humans use another TCastleTransformReference and start “walk” with 0.1 second delay etc. I realize this is quite some additional work – alas, we don’t have a better solution for it immediately available.