Coordinating animation channels

I have defined many animations for a model including things such as walking, jumping etc. In each case I’d like to be able to play the animation with hands in different positions depending on what they are holding. That’s no problem: I have defined separate channels for different sets of bones and am able to run the animations in parallel just as the tutorial says. The issue I have is that some animations (e.g. swinging on a rope) involve animating all bones in the model while others (e.g. closing and opening a hand) involves just a few.

My question is about best practice when I’ve defined several channels and now need to play an animation that covers more than one of them. The options seem to be:

  • Define separate animations for each channel and play them together. This makes modelling more difficult because I would need to animate each section separately which is hard to visualise (in Blender in any case).
  • Define one animation for the model and then remove all other channels before playing it, then replay the animations for different parts of the model once it’s complete. This is possible but awkward (e.g. AnimControl doesn’t have a method for removing channels so I need to remove them all and create a new channel each time).
  • Define one animation for the entire model and then play it through all channels. Each channel would then need to have the correct bones added to make sure the influences do not overlap.

Which of these is best or are there other options for this?

If the final option is the correct one, is there a way to remove a bone from an AnimChannel? Ideally I’d like to be able to say something like:

bodyChannel.addAllBones();
bodyChannel.removeBonesInChannel(handChannel);
bodyChannel.removeBonesInChannel(armChannel);

Nice thing about that would be that I wouldn’t need to list all the bones and the code guarantees no overlap. But there doesn’t seem to be any way to remove a bone.

Advice appreciated. If there’s a good tutorial covering this stuff I’d love to hear about it.

I don’t get your issue.
If you already defined several channels, you just need to play whatever animation on whatever channel.
Like :

bodyChannel.setAnim("run");
handsChannel.setAnim("grab");

You don’t need to remove a channel, you can call reset(false) on it to reset its animation

Let me explain with an example. Let’s say I have the “run” and “grab” animations running on channels influencing different bones. The correct bones have been added to each of those channels so that they don’t interfere with each other. Now I want to run a new animation “jump” that influences bones across both channels. What do I do?

I gather from your answer that you would suggest having a different channel that contains all bones and I play the animation in that channel and reset all the others? Or is it better practice to just leave all bones in all channels and make sure the animations aren’t overlapping? In which case it doesn’t matter which channel I play it on.

You can just play the run animation on both channels.

Thanks for the suggestion. That certainly seems to work. But it seems to be the opposite to nehon’s suggestion to play on one channel and reset the others. I’m assuming this is a pretty common requirement for JME users: do you have a suggestion on best practice?

let’s say you have 3 channels : handsChannel with the bones of both hands, legChannel with the bones of both legs, and bodyChannel with all the bones. bodyChannel contains bones that also belongs to other channels.
In your example you can play “run” on the legChannel, “grab” on the handsChannel, simultaneously.
Now if you want to play the “jump” animation you can play it on the bodyChannel. Note that you’ll have to call reset on all other channels before to not interfere.

1 Like

Ok that makes sense and is certainly easier than messing with the animations or trying to change the bones in a channel. I’ll go with that model.

thanks for your help.