# A Math Based Personality For Games

We make no apologies for being hardware focused here at Hackaday, but that doesn’t mean we aren’t occasionally impressed by a particularly inspired feat of bit wrangling. For example, [t3ssel8r] has taken a break from his game to discuss his procedural animation system and the beautiful math behind it.

Sometimes, rather than having specific keyframes, games will instead use procedural animation. This means that the position is determined on the fly rather than a predetermined set of positions. Developers can use the combination of IK or FK (inverse or forward kinematics) to solve for rotation and positions of the joints that will place the end at a specific position. Particularly with crawling multi-limb things, it’s pretty easy to put a limb on the ground and keep it there until it’s too far away, pick a new spot, and move it there. It’s simple code to write and looks convincing. It can handle complex terrain and situations with different limb positions.

However, it doesn’t offer the chance to inject some life or personality into the movement as keyframes do. [t3ssel8r] goes through the equations and reasoning behind his semi-implicit Euler solver-based system. There are some fantastic explanations in the video, but the short version is that he has three parameters to control the system’s frequency, dampening, and initial response. This allows him to tweak the behavior in a somewhat intuitive manner. One problem is stability; if the timesteps get too large, the position quickly explodes outwards. Using eigenvalues (who ever thought you’d use those) to determine the minimum timestep allows the system to remain stable and take multiple smaller steps when needed or just bound the change temporarily.

If you’re looking for more animation, this blender plugin renders your PCB traces in a new light.

## 18 thoughts on “A Math Based Personality For Games”

1. RW ver 0.0.3 says:

All enquires to Ministry of Silly Walks: Cybernetic Division, London LW1.

;-)

1. RW ver 0.0.1 says:

Heh, what was that Commodore 64 (And other ports) game that must have inspired it? Track and Field, Summer Olympics or Daley Thompson’s Decathlon or something like that.

2. Danjovic says:

Fascinating! Have never seen conrol theory so easily explained. Thanks for the article!

3. The Commenter Formerly Known As Ren says:

In the video, what do the left and right screens of the animation represent?

1. fiddlingjunky says:

I think left is the raw model, right is with the pixelation and lighting effects used in the game it’s intended for applied.

4. Pete says:

I’m showing this to my 16yo son who loves to play games, and wants a career in engineering, but thinks calculus is a waste of his time…

1. RW ver 0.0.1 says:

Trick him into it… like writing a program to add up all the little bits of area under the curve…

2. sjm4306 says:

Ask him to come up with a solution that solves the same problem as this article but doesn’t use calculus. He’ll either have to really think outside the box or come to the conclusion that calculus isn’t a waste of time for this problem. In either case it should be a valuable experience for him.

3. HaHa says:

He’s 16.

The explanation that will get him is:
Calc gets you money which gets you power, both of which get you pus^h^h^hgirls.
He’s just seeing the terrible ratio in the calc class and doesn’t yet understand.
He’s not really wrong, calc won’t get him laid directly. Only thing that matters to a 16 YO.

Also it’s spelled ‘calculus’ but pronounced ‘calcuseless’.

He could just be bad at math. My freshman class (at the start of the year) in engineering was bigger then the rest of the school. Seats opened up fast though.
World needs ditch diggers (Civils) too.

1. RW ver 0.0.1 says:

I had a period of thinking I was bad at math, turned out I was bad at debugging, like spotting all the signs I’d dropped, and things I’d failed to carry etc.

1. HaHa says:

There are two kinds of people in the world.

Those that think math is hard and those that quit studying math while it was still easy.

Dropped signs? Failed to carry?
Arithmetic?
You might, in fact, be bad at math. It appears to have gotten hard for you very early. Can you add/sub fractions?

1. sjm4306 says:

There are in fact 10 kinds of people in the world … those who understand binary and those who do not …

2. fiddlingjunky says:

The second group of people you mentioned is, for the most part, a subset of the first.

I’ve had plenty of profs who understood the subject plenty well enough but needed a very heavy proofread of anything they put out. Why the spite?

3. Float says:

If you ask most mathematicians, arithmetic barely qualifies as math. It stands to reason that if you’re bad at arithmetic, you might still make an excellent mathematician.

4. Float says:

Lot of people here saying to trick him or pander or whatever but the bullshit meter is a sensitive one at that age. Don’t lie to him or play it up. It’s the reason most of the equations we use even exist, and that’s inspiring in its own right.

Pardon me if I’m preaching to the choir but algebraic solutions are faster computationally and often easier to use for humans, it’s just a lot of the times calculus is what gives you those solutions. You can’t expect them all to be handed to you in a neat little list covering every situation (stack overflow only gets you so far =P), as an actual engineer you have to be capable of deriving them and reasoning about them from first principles, and that’s done very often w/ calc

(though not always – I think seeing the various Maps of Mathematics is probably really what inspired me to settle down and blow through calc so that I could get to linear algebra -> graph theory and combinatorics. Seeing how many more fields of math there are just made my rebellion from the gut-level feel just a little more petty and silly, you might consider googling a few for him and researching a few more examples)

Beyond the mechanical pieces they give you in calculus it’s just a whole different way of thinking about systems that change over time.

5. RW ver 0.0.1 says:

Everyone worries about spotting the rise of Skynet, but nobody worried this is the rise of Sirius Cybernetics Corporation that may inflict untold misery on the galaxy? :-D

6. Ostracus says:

I imagine those who work at Boston Dynamics are plenty familiar with this.

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.