Are Code Based Animations and Triggering Animations with Code Possible?

Wondering how to accomplish a certain animation task? Ask here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
DigitalDesignDude
Posts: 14
Joined: Tue Nov 14, 2023 6:02 pm

Are Code Based Animations and Triggering Animations with Code Possible?

Post by DigitalDesignDude »

Hello all,

I'm new to using MOHO and am experienced with software like After Effects and Adobe Animate where you create dynamic or code-based animations using JavaScript or ActionScript.

I see that MOHO supports scripts for automating things like editing art and setting up rigs quickly, but does MOHO allow you to code dynamic animations or use code to control what animations are played?


For example, I would like to make an animated explainer video where after a character finishes talking, code would randomly select and tween to one of my premade looping idle animations.


I'm still learning about MOHO Actions, but from my understanding, they can be used to re-use animations and are the closest thing in MOHO to using something like Adobe Flash/Animate's Symbols. Though I'm unaware if there is a way to trigger Actions randomly from the timeline and if the timeline even allows for keyframes that contain code in them like in Adobe Flash/Animate.


Thank you for any information or assistance regarding this!
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Are Code Based Animations and Triggering Animations with Code Possible?

Post by synthsin75 »

With a button or menu script you can use random number generation to select and then insert an action into the timeline. But you'd need to activate the menu or button script.

You could only do this automatically from the timeline by using a layerscript and having a specific trigger, like a hard-coded frame number or a specific keyframe value in a specific animation channel, etc..
User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Are Code Based Animations and Triggering Animations with Code Possible?

Post by hayasidist »

The thing about moho is that it's not a "playback" program; it's an "editor" program. So you can create all the elements to do what you want and (as Wes as indicated) there are ways to get the program to jump around the timeline and play selected sequences BUT: you're playing back in an editor not in a presentation program (cf e.g. Premiere and VLC media player).

Once upon a time there was Motion Artist - a "sort of" companion program to (as is now) Moho that did go some way towards what you're asking, but it fell far short of having the sort of programmable stuff you're looking for.

If it really is "pre-defined" sequences played in a user-controlled or random fashion (e.g. for Computer-based learning type applications where the next segment is chosen depending on the user's response to the first) then I'd be tempted to use moho to create the segments then use a dvd authoring program to provide the framework and code to control transitions between the segments.
User avatar
DigitalDesignDude
Posts: 14
Joined: Tue Nov 14, 2023 6:02 pm

Re: Are Code Based Animations and Triggering Animations with Code Possible?

Post by DigitalDesignDude »

Thank you for your responses!

If I understand correctly, any animating properties must be defined in the timeline as keyframes in order to show up in my exported video?

Thus, I could use a script to automatically generate all those keyframes in the way I want, but in the end, I would have a timeline full of hardcoded non-dynamic keyframes.

That is workable but it is not as convenient to edit if I find out my script or animation needs adjustments. I would likely have to delete all the keyframes and re-run the script.



In comparison, Adobe After Effects allows you to generate a random colour animation using some code as shown in the below video:

https://youtu.be/xrKMeeFrMxg?si=Cy4EsdL5JU32ymdQ&t=242

Does MOHO have a similar way of using code that doesn't involve hardcoded keyframes?
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Are Code Based Animations and Triggering Animations with Code Possible?

Post by synthsin75 »

Layerscripts (embedded) allow a script to make changes without adding keyframes. They are evaluated on every frame, and can do a lot.

They can change values of things on the fly and effect the render, but for more complex things, like utilizing actions, it's just much simpler to add the keyframes to the timeline. But if you insert actions by reference, that can make them easier to remove or overwrite.

For example, you could set a timeline marker on a frame, and when the layerscript gets to a marker with a specific name, it could insert a random action by reference. As long as that marker is on the same frame, it would just overwrite that action reference each time you play the timeline across it.
User avatar
DigitalDesignDude
Posts: 14
Joined: Tue Nov 14, 2023 6:02 pm

Re: Are Code Based Animations and Triggering Animations with Code Possible?

Post by DigitalDesignDude »

Thank you synthsin75 for further explaining things to me!

I'll have to try out using embedded layerscripts when I can.

And yes I hope to use Actions by reference along with Cycles interpolation to make re-useable and editable looping animations in a similar fashion to Adobe Flash/Animate's Symbols feature.

I hope I'll continue to find other workarounds for achieving other things that I can do in After Effects and Flash but this is a good start.

Thanks again!
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Are Code Based Animations and Triggering Animations with Code Possible?

Post by synthsin75 »

Glad to help. Welcome to Moho scripting.
Post Reply