A script to place keyframes at every other frame

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

Post Reply
User avatar
Posts: 378
Joined: Thu Feb 15, 2007 5:41 am

A script to place keyframes at every other frame

Post by jhbmw007 » Tue Dec 04, 2007 5:55 pm

I do my animations at 24 fps- but sometimes I think body movement or interpolated mouth movement should be set to 12 fps. But if I set the project to 12 fps, then the character movement like walking (I usually use layer translation for this) would not look as good.

Is there a way to select or specify a group of keyframes in the timeline (that are set to "smooth"), and have keyframes inserted automatically on the two's, and then have all the frames changed to "step"? This smells like a script to me...

Basically what I want is where all bone and point movement is done at 12 fps (on two's), and all layer translation is done at 24 fps (on ones). I'm sure slowtiger's going to step in and say I'm confusing framerate with fps or whatever- but do you understand what I'm saying? I want my character to look smooth as he moves across the screen- but not so silky smooth when he waves his hands...
User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Tue Dec 04, 2007 6:47 pm

I think you are right... you are confusing things a bit. If the animation is 24fps nothing else could be 12.

So let's think about what the script should do:

You have keys that are smooth. You may have more than 2 frames between each key. You want the script to place keys between each key you placed so it comes "close" to a key every other frame and then set each key to step interpolation.

Is this about it?

Sounds doable but not "easy". There might be problems when 2 keys are right next to each other... only from a scripting aspect. You don't want to overwrite an existing key with a new one. You might have spots with 3 keys jammed together on each frame... that isn't your problem I'm just thinking out loud.

Also you wouldn't have a fun time making any edits after applying the script.

To make it more "usable" it would be best to make this a menu script and have it work on ANY layer. It would just put keys between any keys that exist for any animated property of that layer.

Not promising anything but it sounds simple enough. Maybe someone else has a simpler alternate solution that doesn't require scripting.

User avatar
Posts: 378
Joined: Thu Feb 15, 2007 5:41 am

Post by jhbmw007 » Tue Dec 04, 2007 9:54 pm

Basically I think you got it. You would create your animation as you normally would- let's say it's set to 24 fps (from here on now I'm not going to mention fps- because our project's at 24 fps and that's that)... The script would only be applied AFTER all animation is done- you would already know if your happy with the movement watching it as it is- the script is just to "unsmooth" out some parts of the animation.

The script would prompt you for what items you want to apply it to (bone angle, point translation, selected point translation, etc) and ask for you to specify the to and from frames. Theoretically speaking- it should be okay if the script then just puts in keyframes at every other frame- if there are 3 keyframes right next to each other it shouldn't be too noticable when watching the animation. Then the script would need to apply the "step" setting to all the keyframes after they have been keyed- as well as any of the existing keyframes that were there before the script was applied.

FOr example- let's say I have a bone with keys on frame 1 and frame 10, where it's smooth movement from 1 to 10. I open the script- which then puts keys at 1,3,5,7, and 9. Then, all the keys in the selection are then set to "step"- 1,3,5,7,9,10. Then that section wouldn't be so smooth looking- but in parts of your animation where there's fast motion, you would want to leave those alone.
Posts: 54
Joined: Tue Dec 05, 2006 9:24 pm
Location: Australia

I second your request

Post by muuvist » Tue Dec 04, 2007 10:36 pm

I know exactly what you want, you want that old Saturday morning TV cel animation look where everything was shot on 2s except panning BGs and fast action. Sometimes the single frame animation looks too smooth and robotic.
It's probably best to describe it as 12 "images" per sec shot at 24 fps. It would also be good to have the option for 3s and 4s too.
User avatar
Posts: 95
Joined: Sun Apr 22, 2007 1:42 am
Location: Australia

Post by AngryMonster » Tue Dec 04, 2007 11:23 pm

I don't know if this is called for ...

And I don't know how you are doing your dialogue.
But to get snappy dialogue

- don't let AS take care of your tweens
- create keyframes close to your major mouth shapes - so that they slow in and out.... but make them EXTREME slow in and outs.

The above goes for all animation - it is a simple principle.
If you feel that part of your action needs to be 12fps - instead try the above to the entire action - we call it favouring(favoring), as in favouring one key then the other. The more extreme you favour a key - the more snappier the action will be.


If I where to animate a real fast piston.

Lets say we had to do a 4 frame cycle. I would put 2 keyframes real close together in the down position - and 2 keyframes close together in the up position - the closer the sets of keys are together the snappier the piston action. Also, I would not worry about a frame between the up and down positions. One thing to remember about animation - the start and finish of an action is usually the most important part.

Sorry - not really about scripting is it?!
Post Reply