23 Replies Latest reply on Jan 18, 2012 2:34 PM by fhxfhx

    Exchanging Constraints

    fhxfhx Level 1

      Parenting is a way of constraining one layer to the other. Is there a way to animate parenting, so that the layer that is to be constrained, changes horses (parent layers) during the course of animation ?


      In may case a hand should drag different objects into the visible area. each object has it’s own position animation and the hand should follow this exact position-animation of each object for the time of each particular animation.


      Alternatively probably the objects can be parented to the hand instead, but then I need to release the paternity as soon as each drag-in-screen object reached its final position and the hand moves on to the next object to drag it into the screen.


      Or is there another concept that is used for this type of task ?




        • 1. Re: Exchanging Constraints
          Dave LaRonde Level 6

          There isn't a way to change a parent layer directly.  It can still be done by splitting the child layer at the point in time where the change should occur and parenting to the other layer.

          1 person found this helpful
          • 2. Re: Exchanging Constraints
            fhxfhx Level 1

            thx for reply. Guess you mean to work with many child copies, each either own animation or parented constraint, by making a copy of layer at each exchange position during animation. Only thing with this solution would be that animation changes would require re-adjusting adjacent animations as well ... won't re-adjust automatically.

            • 3. Re: Exchanging Constraints
              Dave LaRonde Level 6

              You can do it that way, or you can simply split the layer:  put the CTI at the point where re-parenting should occur,highlight the layer and hit Cmd-Shift-d (Mac).  The layer splits.  Change the parenting.

              1 person found this helpful
              • 4. Re: Exchanging Constraints
                fhxfhx Level 1

                Thx Dave !

                • 5. Re: Exchanging Constraints
                  fhxfhx Level 1

                  parenting exchange animation could be a great future feature for those kind of animations.

                  • 6. Re: Exchanging Constraints
                    Dave LaRonde Level 6

                    If you think it's important, file a Feature Request.


                    Someone else may have asked for the same thing, but the squeaky wheel gets the grease.

                    • 7. Re: Exchanging Constraints
                      Rick Gerard Adobe Community Professional & MVP

                      Parenting is not keyframeable but you can stack up some nulls as parents for each layer. Then you could tie the null to the position of the hand based on in and out point for the null with an expression. I don't think I can write that expression in my head. I'll try and get to it later but it involves valueAtTime(time), inPoint, outPoint and if else statements. The trickey part is to maintain the offset.


                      I'm prety sure that I've got an old project lying around on my main machine that does exactly this. I find it more usefull than splitting layers, although that's a very quick and easy approach. It just involves more fiddling when you go to edit the timing of everything. Come to think of it I think I used markers and then just moved the markers around set up the timing.

                      • 8. Re: Exchanging Constraints
                        fhxfhx Level 1

                        just did feature request it

                        • 9. Re: Exchanging Constraints
                          fhxfhx Level 1

                          if it can be solved via expression that'd be really great. That would allow single adjusts on the fly, without domino effect to adjust adjacent animations as well, which then would be by hand, since the layer split is only as long as it is still all 1 path.


                          Then you'd have built another, in my opinion quite important missing AE feature, next to the other arrow solution a few weeks ago at http://forums.adobe.com/message/4080035#4080035

                          • 10. Re: Exchanging Constraints
                            fhxfhx Level 1

                            up to now I ended up keyframing every single keyframe to get the hand positioned right to the other objects, this takes hours. ... isn't there a better way to do this ?

                            • 11. Re: Exchanging Constraints
                              Rick Gerard Adobe Community Professional & MVP

                              All you should have to set is start and end keyframes for each position of the hand. You can then adjust the path in the Comp panel with the bezier handles. You're not trying to put a keyframe in every frame are you?


                              And yes, animation can take hours, but there are shortcuts like motion sketch and recording movement of puppet pins.

                              • 12. Re: Exchanging Constraints
                                fhxfhx Level 1

                                ... actually yea I have to go the route of splitting the layer. I'll do that now

                                • 13. Re: Exchanging Constraints
                                  fhxfhx Level 1

                                  I actually was keyframing every single keyframe by using a marker on each object to position my hand to it. In the meantime I was using an invers kinematic but that got to complicated interferences of oall different moves and rotations so I went back to stiff hand-arm

                                  • 14. Re: Exchanging Constraints
                                    Dave LaRonde Level 6

                                    To echo what Rick says, this really isn't all that tough.  Here's what one cycle of "hand moving object" might look like:

                                    • The object is in its starting position.  It's not parented to anything.


                                    • Animate the hand from its starting position until its over the object.  If you plan to pause the hand for a moment, using the Toggle Hold Keyframe on the incoming keyframe eliminates the hand's position drifting between the incoming and the next outgoing keyframe.


                                    • While the hand is paused over the object, split the object layer and parent it to the hand.  The object now moves with the hand.


                                    • Animate the hand until the object is in the correct ending position.


                                    • Once the hand stops in the correct position, split the object layer again.  Change its parenting to None.  When the hand moves away to grab the next object,  this first object remains in position.


                                    See?  It's just not as tough as you want to make it!  It just requires a little planning for the beginning and ending positions of your objects. 

                                    • 15. Re: Exchanging Constraints
                                      fhxfhx Level 1

                                      thx gotit, so I constrain the objects to the hand for a while and then I unparent them ... didn't know that parenting could be toggled on of during time. Thought that the split creates a duplicate of object which then is unparented and just stays there, while the parented one needs to end visibility.

                                      • 16. Re: Exchanging Constraints
                                        Rick Gerard Adobe Community Professional & MVP

                                        It may be too late for your project but I dug up the expression that I used to link attach one layer's position to another one based on layer markers. It was actually quite simple. Here's the expression as it is applied to the layer being picked up by the "hand" layer.


                                        // define variables
                                        h = thisComp.layer("hand").position;
                                        grabTime = marker.key(1).time;
                                        releaseTime = marker.key(2).time;
                                        startP = h.valueAtTime(grabTime);
                                        // calculate position offset
                                        diff = value - startP;
                                        // logic 
                                        if (time < grabTime) {
                                                  np = value 
                                        if (time >= grabTime) {
                                                  np = h + diff
                                        if (time >= releaseTime) {
                                                  np = h.valueAtTime(releaseTime) + diff

                                        Let me explain the exprression. The first 4 lines define variables. The first is a layer in the comp named "hand." The second is the time of the first layer marker which is set to when we want to grab the layer. The third is the time of the second layer marker set to when we want to release the layer. The fourth is is used to get the starting position of the hand layer at the time the layer is grabbed.


                                        So far that's prety simple.


                                        Next comes the only calculation in the expression. We need to account for the difference in position between the hand layer and the hand layer. There's nothing more to it than simple subtraction.


                                        The logic part of the expression is a simple set of conditional statements. When the time is less than the grab time marker the layer rests in it's original position. When the first marker is passed the new position of the layer is the same as the hand layer but we add back in the difference or offset between the layers. The last arguement simply says when you pass the second marker (releaseTime) leave the layer at the position + the offset where the hand layer was when it was at the marker.


                                        I hope this helps. It's a goodie that I should have had more accessible.


                                        Here's a sample project including a CS5 version.


                                        • 17. Re: Exchanging Constraints
                                          fhxfhx Level 1

                                          whow Rick you've smash hit it again ! that's great stuff, I'll be using this for a lot of tasks now.




                                          • 18. Re: Exchanging Constraints
                                            fhxfhx Level 1

                                            ... the sample project file seems missing ...

                                            • 20. Re: Exchanging Constraints
                                              fhxfhx Level 1

                                              Hi Rick, I have seperated many pieces of the movie in pre-comps and want, if possible, to do the hand animation on the final parent comp. Is it possible to grab a layer in another comp as well ?

                                              • 21. Re: Exchanging Constraints
                                                fhxfhx Level 1

                                                I love it !

                                                • 22. Re: Exchanging Constraints
                                                  Rick Gerard Adobe Community Professional & MVP

                                                  You can just grab the pre-comps if each object is in a preComp that's in the main comp. If you want to grab separate layers inside the pre-comp they you'll have to rewrite the expression to point the hand layer to the hand in the different comp. You'll have to split your comp windows, lock the main comp, then set the start position in the nested comp while looking at the position in the mainComp.


                                                  To fix the expression all you have to do is rewrite the definition of h so that it points to the Main comp instead of a layer in the nested comp. It looks like this if the main composition is named mainComp.


                                                  h = comp("mainComp").layer("hand").transform.position; 


                                                  That's all there is to it.

                                                  • 23. Re: Exchanging Constraints
                                                    fhxfhx Level 1

                                                    ok, that's a pretty good pipeline now for animations with moving around stuff.