• Runtimes
  • Procedural animation help

Hey all,

I have what I think is a procedural animation question, although maybe there's another solution.
I’ve got a variety of sword animations, and I want them to branch to a “rebound” animation if they’re blocked.
But the angle of the weapon is specific to each animation, and I’d like to have a general purpose solution instead of animating a branch from every source animation.

So I was thinking I could create a procedural animation - keep track of the arc of the weapon in code, and then if it rebounds use that to determine the appropriate target rotation / position.

What's a good way to solve this problem? And how would I even go about creating a procedural animation for Spine? I'm currently procedurally setting the rotation of a single bone, but encapsulating that into an animation sequence is something I'm totally unfamiliar with.

Thanks!

Related Discussions
...

Try mixing from a sword swinging animation to a rebound animation which starts with the sword is back in the rebounded position. The crossfade that AnimationState does will cause the sword to transition to the rebounded position over time. This is probably good enough and simpler than writing code to rotate the bones for the sword.

Depending on where the sword is when the rebound animation is played, your bones may rotate the wrong way around. You can either use code to stop this or have multiple rebound animations to avoid the problem.

Yeah, that's more or less what I'm currently doing - I just have a generic rebound that I blend to. It works okay, but it's definitely noticeable that it's not matching the motion of the attack. Not the end of the world, of course, but I'm interested in augmenting my animations with game data to create a more interactive model.

What makes it noticeable? Maybe post a GIF? LICEcap makes it easy to record a GIF of your game.

There are a number of things you could do, depending on why it is noticeable. Maybe you can adjust the mix time, use multiple rebound animations and choose the most appropriate one based on the sword's rotation on impact, etc. Maybe you just need to adjust your rebound animation, likely it should start in a pose with the sword already back in the rebounded position, this way when you blend to it, the sword moves (roughly) from wherever it impacted to the rebound position. If you animated the sword moving from a front pointing position to the rebound position, the effect won't be the same.

Doing procedural animation is just manipulating the bones through code. Generally you'll have a state machine that runs the appropriate code based on the state of the skeleton. Eg, you might set the state to "impacted" and then adjust the bones over time to reach the rebounded pose.

Here's what it looks like now:
http://gfycat.com/TanSerpentineArctichare

I could definitely just create a differently angled rebound and use it for that angle of attack. In this particular case, that's probably the best answer, since if I have a clockwise and counterclockwise rebound, that pretty effectively covers it.

I started thinking about this after seeing some of the physics integration in the Unity demos. Partially animation driven and partially physics / engine driven characters are a really interesting subject, and obviously with ground constraints there's already some of that.

Yeah it seems you just need a rebound animation for the lower attack. The top attack looks pretty good.

The Unity runtime is just manipulating bones. 🙂 Using physics makes for some neat effects. You could write your own, simplistic physics to get bones to react realistically. Then you can have bones in Spine that you don't animate and at runtime have them controlled by the physics (eg, a cape). This would be a neat addition to the official runtimes


simplistic physics for driving bones. In fact, using one of the various physics scripts from the Unity Asset store can give better results that using Unity's actual physics.