ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Puppet pin positions automated along a motion path

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Luke Galiazzo
Puppet pin positions automated along a motion path
on Feb 13, 2011 at 1:29:24 pm

Hi there!

I have an AE problem requiring an urgent solution and thought I'd ask on here in case someone knows the magical answer. :)

I have a .psd element that I need to animate in a sequence. I have used the puppet pin tool as it is a straight horizontal image of a 'sandsnake' that I need to have diving in an 'over and under' manner. It is only in 2D, so that's easy enough. However, while I have that animation in place and could easily get it to go across the screen, I actually need it to leap up and over as it passes a certain point on screen.

Here is the problem, as this messes with the puppet pins if I then try to animate the already loop-animated snake. I've set up a motion path and was trying to establish keyframes for the 'head' puppet pin and then use expression code on the remaining pins so that their take their position at any given time as a direct copy of the position of the 'head' puppet pin, albeit from a time 12 frames or even 1 second ahead.

This way, I thought I could have the puppet pins move along the motion path in the arc that I need and then modify the code so I could add the slight wiggling movement on top of that.

I hope I'm explaining myself well enough, it's late and I'm new to all this. If it helps any I could describe the motion as similar to that in Maltaannon's CG snake animation tutorial except that my snake is a side-view and a still image with puppet pins, rather than multiple segments following a leader via a controller.

I'd appreciate any help you could give me in the next 24 hours. If not, then I'll have to work out a substitution on my own. Thanks in advance :)


Return to posts index

Dan Ebberts
Re: Puppet pin positions automated along a motion path
on Feb 13, 2011 at 5:47:25 pm

This solution makes some assumptions. One is that the pins are numbered such that Pin 1 is the leader(head), Pin 2 is behind that, etc. It also assumes that you haven't renamed the pins. Before you start and after you stop animating the lead pin, all the pins will of course be in the same location.


delayFrames = 4;
p = effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 1").position;
idx = parseInt(thisProperty.propertyGroup(1).name.split(" ")[2],10)-1;
delay = idx*framesToTime(delayFrames);
p.valueAtTime(time-delay)



Dan



Return to posts index

Luke Galiazzo
Re: Puppet pin positions automated along a motion path
on Feb 13, 2011 at 10:22:59 pm

Thank you so much for the quick reply. If I'm understanding right, I should keep that code as is and use the exact same code for each puppet pin? If that's the case, despite the head pin (pin #1 as you assumed) being animated via keyframes along the motion path, the other pins don't follow along at a distance, rather they all bunch on the one position throughout the sequence.

So, they all stay on pin 1's position the entire time, all 8 pins move across the screen at the Pin #1 position.

Perhaps I'm misunderstanding the code (I'm extremely new to expressions)?


Return to posts index


Dan Ebberts
Re: Puppet pin positions automated along a motion path
on Feb 14, 2011 at 12:19:24 am

Yes, all the pins except #1 get the expression, pin #1 gets the keyframed animation. Does it move pretty slow? Maybe you need to increase the delay. I set it up for each pin to be 4 frames behind the previous one.

Dan



Return to posts index

Luke Galiazzo
Re: Puppet pin positions automated along a motion path
on Feb 14, 2011 at 5:06:53 am

I tried and again and technically it works but I'll still need to tweak some things. Despite the puppet pins traveling along the same path and being on what could be considered the 'spine' of the image, there's a lot of deformation in the mesh. I'm guessing I'll have to sort out a way of compensating for that...

Thank you so much though. This code is exactly what I was trying to come up with, if you have any thoughts on the mesh deformation issue I'd love to hear them.


Return to posts index

Nick Fox-Gieg
Re: Puppet pin positions automated along a motion path
on Sep 4, 2013 at 2:50:26 pm

Neat! I put a version of this in a UI panel to automatically apply the script to any number of pins:
https://github.com/N1ckFG/AEToolbox

...any thoughts on how you'd modify the script to anchor the last pin--a tentacle, instead of a snake?

Thanks!
Nick


Return to posts index


Graham Thorne
Re: Puppet pin positions automated along a motion path
on Mar 5, 2014 at 10:28:47 am

Any ideas?



Return to posts index

Nick Fox-Gieg
Re: Puppet pin positions automated along a motion path
on Mar 5, 2014 at 1:39:55 pm

You mean the UI panel isn't compiling? Haven't tested it on older than CS5.5, unfortunately.


Return to posts index

Graham Thorne
Re: Puppet pin positions automated along a motion path
on Mar 5, 2014 at 2:03:42 pm

Nope. Im on CS6. New to all this so not sure how to resolve it.

I would like to do exactly what is mentioned above but I have no clue where to past the:

delayFrames = 4;
p = effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 1").position;
idx = parseInt(thisProperty.propertyGroup(1).name.split(" ")[2],10)-1;
delay = idx*framesToTime(delayFrames);
p.valueAtTime(time-delay)

Bit.


Return to posts index


Xavier Gomez
Re: Puppet pin positions automated along a motion path
on Mar 8, 2014 at 9:04:35 am
Last Edited By Xavier Gomez on Mar 8, 2014 at 9:19:52 am

@Graham Thorne: the script doesnt have 2001 lines. If you copied it in the navigator and pasted it in a new jsx in ExtendScript, you might have copied more than the script code. For me it works fine.

@Nick: Thank you for posting this.

Regarding the snake/tentacle thing, it is not a straightforward modification...

For a "snake", there is only one motion path that is common to all elements in the trail. All elements follow that same path, but at different times.

For a "tentacle", if you want to do something interesting with it (ie animate it) you'll need to animate the underlying curve itself, and there can be as many different curves as they are frames in the animation. It's a lot more complicated (animation work). You can't do this with an expression.

Xavier.


Return to posts index

Ginger O'Toole
Re: Puppet pin positions automated along a motion path
on Sep 9, 2019 at 5:41:55 pm

This has probably been solved eons ago however I will paste my system here in case anyone else looks it up. I was doing something very much the same last night in my old version of After Effects CS5.5

If you have a snake or similar image and apply puppet pins and want it to move along a motion path and to warp along with the path this is how I did it;

Draw a motion path, say a long wavy line or a spiral, place your snake or image at the start of the motion path lining up your leading puppet pin on the first point of the path. Now copy and paste the motion path (motion path 2) - this will be for the next puppet pin (puppet pin 2) to follow - using the pen tool click the second motion path and add a new point to the path before the first point in line with your image's second puppet pin (you might have to do this by eye or maybe the snapshot button will work to show exactly where the pin is?).. ... and do this for each puppet pin - basically give each puppet pin its own motion path that is extended back from its starting point to line up with each pin.

Now you can copy the "path" value of each motion path layer and paste onto the "position" value of each puppet pin. So number your motion path layers and puppet pins accordingly - motion path 1, motion path 2... puppet pin 1, puppet pin 2 ... etc

HOWEVER! Before you paste your motion path values onto any puppet pins... using a copy of your snake or image, place it with the first puppet pin at the ending point of the path, now position the other pins to line up on the path where you would like them to finish. You can use the pins now as a guide to add an extra anchor point on each pin's motion path and snip the end off so now each pin has its own start point, end point and their own motion path. I forgot the end point at first and you can imagine what happens, every pin ends on the same position which crumples up the image towards the last frame.

Now you can copy each motion path's "path" value onto their relevant puppet pin's "position" value for your original snake/ image and it will now move and warp perfectly along the path, (which is now actually several motion paths on top of eachother). (NOTE: if your puppet pin and image path jump way off position after you paste the values ( which mine always do and i dont know why), in the comp window simply drag it back into position lining it back up with the motion paths you originally drew. These path layers can then be deleted.)


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]