Page 1 of 2
How do you animate your units?
Posted: 28 Sep 2010, 08:36
by Beherith
So Ive been thinking of getting into animating some units, but find the whole COB thing a nightmare. I would like to know if anyone has found a more streamlined/visual approach to animation.
I also am baffled by all the movements being at constant speed. I would very much like if I could use constant acceleration instead of constant speed. I believe it could offer much more realistic animations.
Also, Im in search of some kind of method to rig the models; in my words, it would mean that I loaded up the model in 3d, and maybe set each joints degree of freedom and movement limits, and if I push and pull a peice, it would move the peices. Kind of like if i dragged the left foot forward, it would also adjust calf and thigh positions to accomodate for that movement.
Please offer any advice/experience you have in this matter.
Re: How do you animate your units?
Posted: 28 Sep 2010, 10:10
by Argh
I animate by building the key frames in UpSpring, writing down all the numbers, then building the animation steps, then adjusting the timing via a constant. It's the easiest way, really- it rarely takes me more than an hour to do animations for simple stuff like a typical robot with walkcycle and firing animations.
You don't need to use constant speeds. What you need to do is to have constant time.
There's no rule saying that during a period of 1000, one rotation event can't take 700, another 300, for example. Using constant time means that you have a value that everything else is relative to, and lets you adjust timing for the whole sequence by changing just one number. If you want it to be faster, divide the constant in half, and now it's 350 / 150, for example.
Getting fancier than that is pretty expensive. The cheapest way to do true acceleration would probably be to build a series of move-now / sleeps and use smoothAnim interpolation, but I avoid it like the plague, because it's relatively expensive. Even fancier than that would be a ratcheted move-now that did true acceleration per gameframe with interpolation... you don't want to know how much that will cost, though. It's something you could use for a super-unit or a demo.
As for rigging, UpSpring is about as easy as you can get.
The rest of what you're talking about is building an IK system, and it'd just be a waste of time. If you build the keyframes, they're by-definition within your constraints; so your only trouble is if tweens go outside said contraints (happens frequently with double-twist rotations) and the only real cure for that is a tween key that fixes the issue (this happens all the time even in systems with IK btw).
Re: How do you animate your units?
Posted: 28 Sep 2010, 10:19
by Master-Athmos
I also fire up the model in Upspring, do the translations and rotations there and code those values into the script. In contrast to Argh I wouldn't call a walkcycle "simple stuff" and I especially object that this is the easiest way...
It's very hard to get a smooth and believable walk cycle. I spend most of the time looking at things ingame and then changing things as I see fit. That's why I think that there's a huge need for a WYSIWYG editor for animations where you immediately can play the "keyframes" you added in and are able to see if everything runs smooth and believable. The Blender export plugin might be such a solution but I have to admit I've never really tried it...
Re: How do you animate your units?
Posted: 28 Sep 2010, 10:24
by Argh
If you build animations with Lua, you can reload now, apparently, for testing in realtime.
But yes, compared to doing stuff with IK in a real editing suite, it's not fun.
Re: How do you animate your units?
Posted: 28 Sep 2010, 10:40
by Master-Athmos
Argh wrote:If you build animations with Lua, you can reload now, apparently, for testing in realtime.
Which is one of the biggest advantages over COB for me. It really saves a lot of time as you don't have to reload the mod...
Re: How do you animate your units?
Posted: 28 Sep 2010, 11:14
by Beherith
What I meant by constant speed is that joints have infinite acceleration. I would be fine with constant acceleration. But I guess Ill look into the engine and see what I can do.
I think Ill try the blender export plugin. But blender is notoriously hard to use.
Re: How do you animate your units?
Posted: 28 Sep 2010, 11:44
by zwzsg
Master-Athmos wrote:Argh wrote:If you build animations with Lua, you can reload now, apparently, for testing in realtime.
Which is one of the biggest advantages over COB for me. It really saves a lot of time as you don't have to reload the mod...
docs/cmds.txt wrote:/reloadcob <unit_name>
Re: How do you animate your units?
Posted: 28 Sep 2010, 12:20
by rattle
reloading the cobs was kinda broken, some variables got messed up and stuff like that
Re: How do you animate your units?
Posted: 28 Sep 2010, 12:26
by zwzsg
Well, it works for me, but then I kept from TA the habit to initialize all my "static-var" in Create()
Re: How do you animate your units?
Posted: 28 Sep 2010, 12:43
by Beherith
I apologize for the noobish question, but looking at the source didnt clear this up: Whats the difference between move and smoothmove?
Re: How do you animate your units?
Posted: 28 Sep 2010, 12:44
by Masse
Beherith wrote:I apologize for the noobish question, but looking at the source didnt clear this up: Whats the difference between move and smoothmove?
This is purely a guess, but I'm guessing smoothmove has acceleration and deceleration at the ends.
Re: How do you animate your units?
Posted: 28 Sep 2010, 12:52
by zwzsg
smoothmove let the engine interpolate a series of move/turn now separated by sleeps into a smooth movement, that is, move/turn with speed.
I dislike smoothmove because, as every dumb algorithm trying to guess and correct input that's bad in the first place, it fails on anything a bit complex.
If you realised there can be a "speed" after "move/turn", then you do not need smoothmove.
Re: How do you animate your units?
Posted: 28 Sep 2010, 12:54
by Beherith
Thanks zwzsg! That cleared it up, but now im wondering how acceleration can be passed to a move command...
Code: Select all
void CUnitScript::TurnSmooth(int piece, int axis, float destination, int delta, int deltaTime)
{
if (!PieceExists(piece)) {
ShowScriptError("Invalid piecenumber");
return;
}
AnimInfo *ai = FindAnim(ATurn, piece, axis);
if (ai) {
if (!ai->interpolated) {
TurnNow(piece, axis, destination);
return;
}
}
// not sure the ClampRad() call is necessary here
float cur = ClampRad(pieces[piece]->rot[axis]);
float dist = streflop::fabsf(destination - cur);
int timeFactor = (1000 * 1000) / (deltaTime * deltaTime);
float speed = (dist * timeFactor) / delta;
Turn(piece, axis, speed, destination, true);
}
Upon further inspection, it seems that both move and turn have acceleration parameters, but they are both passed as 0:
Code: Select all
void CUnitScript::Turn(int piece, int axis, float speed, float destination, bool interpolated)
{
AddAnim(ATurn, piece, axis, speed, destination, 0, interpolated);
}
void CUnitScript::Move(int piece, int axis, float speed, float destination, bool interpolated)
{
AddAnim(AMove, piece, axis, speed, destination, 0, interpolated);
}
Re: How do you animate your units?
Posted: 28 Sep 2010, 12:59
by zwzsg
Beherith wrote:im wondering how acceleration can be passed to a move command...
You can't!
You can only have acceleration in spin (and even, it only works sometimes).
Re: How do you animate your units?
Posted: 28 Sep 2010, 13:38
by Licho
Wasnt there a branch with skeleton based animations? I think it was to be coded with lua with some high performance stuff done by engine (matrix operations).
Re: How do you animate your units?
Posted: 28 Sep 2010, 13:53
by Beherith
So in essence, I would like the current constant speed infinite acceleration move to be replaceable with a varying speed constant acceleration move.

Re: How do you animate your units?
Posted: 28 Sep 2010, 18:09
by d-gun
Licho wrote:Wasnt there a branch with skeleton based animations? I think it was to be coded with lua with some high performance stuff done by engine (matrix operations).
http://www.youtube.com/watch?v=JwL67-loGWU
posted in 2008
Re: How do you animate your units?
Posted: 28 Sep 2010, 18:45
by Argh
I would like the current constant speed infinite acceleration move to be replaceable with a varying speed constant acceleration move.
That may be possible with Lua as a new command. It's certainly not possible with BOS- if you want acceleration, you need to code it yourself.
I don't really think you
want this, though- the cost of it will be rather high per Piece, as that's going to be the equivalent of a move --> speed command for every rotational Piece every gameframe. Faking it adequately with good keys is a lot easier and cheaper

Re: How do you animate your units?
Posted: 29 Sep 2010, 20:41
by AF
Nobody should be coding new units in BOS unless theyre copy pasting 95% of the code to save time
Re: How do you animate your units?
Posted: 29 Sep 2010, 21:46
by Wartender
i really wish spring had an IK animation system
