Follow more than one path

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

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Follow more than one path

Post by Greenlaw »

ggoblin wrote: Fri Jul 15, 2022 11:36 am Thank you Greenlaw for going to the trouble of recreating your test project for me. In your project the end of your first curve aligns with the start of your second curve, what I had in mind was something different. Say you have two curves M and C and you want the arrow to follow the M first, say between fame 0 and 96 (0% to 100%) and then from frame 144 to 216 for it to follow the C curve (0 to 100%).
Sure...I aligned these two paths intentionally but it's easy enough break the alignment by moving the group. When animating to skip the gap, just transform the position of the group. Be sure the origin of a group is placed where the arrow position ends for each group.

Well, this works in theory anyway. I just tried it and for some reason a step key is interpolating rotation between the steps, which it shouldn't do of course. Normally, I prefer to duplicate a key instead of stepping, so maybe this is a bug that's been here for a while? I need to look at this today and maybe file a bug report. Anyway, probably works if you don't use Step keys.

However there's a simpler way to do what you describe:

Image

In this example, I drew the letters in a single layer and then connected the ends of each letter using Add Points. In other words, this is a single path with multiple shapes. Since there is only a single path, we can just keyframe Follow Path's timing in a single channel...much simpler! After this is animated, Stroke Exposure was animated to match the timing. (I know my timing is a little sloppy here but I have to move on. I'm not sure but maybe I could have copy/pasted values? Probably not but worth looking into if it saves time.)

Image

BTW, I don't think this is an appropriate technique for the example you showed. If it was me, I'd come up with a convincing cheat instead and just move on...but that's because I would never have the time to animate a complex line drawing animation like that line by line.

In the past, I've done something similar in a different program by recording me tracing a drawing and then hiding the traced image. It worked in that situation but this method wouldn't always be ideal either. Hmm...if you're going to do this in Moho, maybe trace the art using Moho's Freehand and then connect the paths? Or draw as a continuous line and use Hide Edge to create the gaps? Not sure that's practical, just a couple of ideas.

Anyway, hope this helps illustrate there are many ways to do something in Moho and it just takes some creative thinking to come up with the right technique for a specific situation.

Here's the second project file if anybody wants to pick it apart...

followMultiplePathsSkipGaps2.moho
Last edited by Greenlaw on Fri Jul 15, 2022 11:00 pm, edited 2 times in total.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Follow more than one path

Post by Greenlaw »

Oh, Another method I've actually used more than once is to draw a mask over the drawing and record that process. Basically, I'm animating an erasure of the drawing and then reversing that as a mask I can manipulate and/or retime. One way to do this is to use the roto brush in After Effects. I guess you can do this in Moho by using Freehand and FBF to create the animated Mask.

So...many ways to do these things.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Follow more than one path

Post by Greenlaw »

Just for fun, I made an alt version where I deleted all the 'skip' frames so the pen can moves continuously...

Image

The pen just follows the path until the very end, where I added some position keyframes to make the little stab. I could have added an SBD to control the pen angle but it was easy enough to keyframe the rotation down when the pen was high, and up when pen was low. If I really wanted to automate that part, maybe I could add a couple of bones and apply an IK constraint.

Another exercise you can try: add a 'Draw' SBD to control the velocity of the pen and stroke exposure.

Download: followMultiplePathsSkipGaps2AltPen.moho

BTW, when you look at the file, you might have noticed that it gets a little out of sync at the second 'P' stroke. I think this is because I didn't start the follow path at exactly the right spot. I'm not going to fix that but just thought it was worth pointing out because I did find that it's possible to copy the Follow Path value to the the Stroke Exposure channel to keep them synced, especially if you use Linear keys. (Which suggests it's probably best to use an SBD to control speed.)
Last edited by Greenlaw on Sat Jul 16, 2022 4:14 pm, edited 3 times in total.
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: Follow more than one path

Post by ggoblin »

Greenlaw wrote: Fri Jul 15, 2022 5:25 pm Well, this works in theory anyway. I just tried it and for some reason a step key is interpolating rotation between the steps, which it shouldn't do of course. Normally, I prefer to duplicate a key instead of stepping, so maybe this is a bug that's been here for a while? I need to look at this today and maybe file a bug report. Anyway, probably works if you don't use Step keys.
I noticed some weird behaviour when I tried, but put it down to me doing something wrong - probably still the case at my end. :D
However there's a simpler way to do what you describe:

In this example, I drew the letters in a single layer and then connected the ends of each letter using Add Points. In other words, this is a single path with multiple shapes. Since there is only a single path, we can just keyframe Follow Path's timing in a single channel...much simpler! After this is animated, Stroke Exposure was animated to match the timing. (I know my timing is a little sloppy here but I have to move on. I'm not sure but maybe I could have copy/pasted values? Probably not but worth looking into if it saves time.)

BTW, I don't think this is an appropriate technique for the example you showed. If it was me, I'd come up with a convincing cheat instead and just move on...but that's because I would never have the time to animate a complex line drawing animation like that line by line.

In the past, I've done something similar in a different program by recording me tracing a drawing and then hiding the traced image. It worked in that situation but this method wouldn't always be ideal either. Hmm...if you're going to do this in Moho, maybe trace the art using Moho's Freehand and then connect the paths? Or draw as a continuous line and use Hide Edge to create the gaps? Not sure that's practical, just a couple of ideas.

Anyway, hope this helps illustrate there are many ways to do something in Moho and it just takes some creative thinking to come up with the right technique for a specific situation.
Thats a good idea, breaking the curve in to shapes.

Oh I appreciate that none of these methods is suitable for manually creating such animation for complex vector art as is usual in SVG files. The reason I was asking was to understand how one would manually do it - best practice, and then the idea was to automate the process via a script. The Lynch example I posted was generated via a script which basically joined all the curves to form one path with sections hidden and stroke exposure used to animate it and follow path used for pencil animation. You idea of using shapes instead of hidden sections is very interesting, I have no experience using shapes in scripts.. I wonder if the overhead is less that way.. will investigate. Thank you.
Oh, Another method I've actually used more than once is to draw a mask over the drawing and record that process. Basically, I'm animating an erasure of the drawing and then reversing that as a mask I can manipulate and/or retime. One way to do this is to use the roto brush in After Effects. I guess you can do this in Moho by using Freehand and FBF to create the animated Mask.

So...many ways to do these things.
Yes I have seen that method often used in AE tutorials for handwriting, its something on my list to investigate. Masks may be the best way for text which have fills to deal with, unlike freehand sketches.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Follow more than one path

Post by Greenlaw »

ggoblin wrote: Fri Jul 15, 2022 11:59 pm Yes I have seen that method often used in AE tutorials for handwriting, its something on my list to investigate. Masks may be the best way for text which have fills to deal with, unlike freehand sketches.
Actually, I have used this for complex drawings several years ago in a game cinematic/trailer. It required a bit of careful planning because I wanted the art to appear to be drawn in a natural progression and not randomly. From what I recall, I broke out the masking process into multiple sequences to make it easier to edit and address any production notes I received. I wasn't using After Effects at the time, so I probably used a roto tool in Fusion or an FBF animation program to paint the 'erasure' progression. (When I think about which programs I used back then, it was probably Painter, which had the ability record brushstrokes, kinda like how Procreate does nowadays.)
Last edited by Greenlaw on Sat Jul 16, 2022 1:52 am, edited 1 time in total.
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: Follow more than one path

Post by ggoblin »

Greenlaw wrote: Fri Jul 15, 2022 11:39 pm Just for fun, I made an alt version where I deleted all the 'skip' frames so the pen can moves continuously...

Image

The pen just follows the path until the very end, where I added some position keyframes to make the little stab. I could have added an SBD to control the pen angle but it was easy enough to keyframe the rotation down when the pen was high and up when pen was low. If I really wanted to automate that part, I could have added an IK constraint.

Another exercise you can try: add an SBD to control the velocity of the pen and stroke exposure.

Download: followMultiplePathsSkipGaps2AltPen.moho

BTW, when you look at the file, you might have noticed that it gets a little out of sync at the second 'P' stroke. I think this is because I didn't start the follow path at exactly the right spot. I'm not going to fix that but just thought it was worth pointing out because I did find that it's possible to copy the Follow Path value to the the Stroke Exposure channel to keep them synced, especially if you use Linear keys. (Which suggests it's probably best to use an SBD to control speed.)
I love the cute pen, and its bobbing up and down! Its something I have not thought about - animating the pen itself - its angle, perspective etc. I suppose its possible in lua to automate the pen angle based on its position on the paper via a smart bone action. Thank you, will investigate.
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Follow more than one path

Post by synthsin75 »

ggoblin wrote: Fri Jul 15, 2022 11:59 pm The Lynch example I posted was generated via a script which basically joined all the curves to form one path with sections hidden and stroke exposure used to animate it and follow path used for pencil animation. You idea of using shapes instead of hidden sections is very interesting, I have no experience using shapes in scripts.. I wonder if the overhead is less that way.. will investigate.
The overhead should be lower with fewer shapes. Hide edge is just a boolean for each segment, where each new shape has all the properties to define the shape.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Follow more than one path

Post by Greenlaw »

Yeah, I imagine a single shape with hidden edges will be more efficient. FWIW, I tried a version of that yesterday and ran into an unexpected error, but I'm not sure if this was a bug or my own mistake. I didn't have time to investigate so fell back to the individual shapes because that behaved predictably for me.
Last edited by Greenlaw on Mon Jul 18, 2022 5:10 pm, edited 1 time in total.
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: Follow more than one path

Post by ggoblin »

Yes that makes sense, more efficient than lots of shapes.

What if we combine all those edges we want to show into ONE shape to keep processing costs down. Is that not possible?
Post Reply