Weekend in the Woods

This post is NOT about Metal. I promise.

I’ve been working on a little side project during the last couple of weeks using two of the newest Crimild’s improvements. Here, take a look:

So, what’s going on here? The game idea is pretty obvious: it’s a platform game. You walk or run and then jump to reach another platform. Or you can fall into the abyss until MAX_FLOAT happens.

But there are two mayor “new” features working together here for the first time: animations and physics.

I introduced the new scene importer earlier this year, now supporting FBX and other file formats thanks to the Assimp library. What’s different in this demo is the use of a new Animator component, allowing us to set states and transitions between poses based on predefined rules.

For example, you can transition from idle to walk animation by linking them with the current horizontal speed. Or, you gan go from any given state to jump if the vertical speed changes. All this is combined with a character controller that reacts to user input.

On the other hand, the Physics system has been improved by supporting different colliders (like box, capsule or mesh). The RigidBodyComponent has been greatly enhanced, too. And all physical objects can now be created from Lua scripts as well.

At the moment, both features are in the “experimental” phase but I’m assuming they’ll be production ready before the end of this year.

That’s it. Let’s go back to Metal…


Integrating Bullet physics engine

I’m proud to announce that Crimild has (real) physics support now thanks to Bullet. Yay!


To be honest, I’ve been running away from this feature for some time, because I always thought that integrating an external physics engine would be an extremely complex task. Well, I’m happy to say that, once again, I was wrong.

A couple of weeks ago I was reading this fantastic introduction to Bullet by Ray Wenderlich and it made me realize that adding physics support to Crimild would be a lot easier than expected. And it was. Here’s the Bricks demo in action, implemented using Crimild and Bullet:

The current implementation has support for convex and non-convex shapes and also for static, kinematic or dynamic objects, but it’s limited to rigid bodies only. Shapes are built from the actual geometry, which is a slow process but provides accurate results. I’ll improve this in the future to add custom shapes support if needed.

Finally, I refactored the update loop to simulate physics using a constant time and all components now include a ‘fixedUpdate’ method that is executed after the physics step is completed. Since physics run at a constant delta, this could mean that the ‘fixedUpdate’ function is invoked more than once per frame. Check out this great article about how to fix your timestep

BTW, today’s is September 13th so Happy Programmer’s Day!