Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions clamp object to orbit around it’s on axis

  • clamp object to orbit around it’s on axis

    Posted by Brad Pickford on October 20, 2012 at 1:09 pm

    Hi Everyone,
    I am trying to create an onscreen (in comp window) GUI. Basically what I am trying to do is create a rotation slider. I have a square box icon that i want to rotate around an offset axis when you drag the object in the x direction. I thought I had a solution but the object spins in either an increasing or decreasing spiral even though I have clamped the position values. I have attached a still image to show the setup, with the parenting and clamping expressions etc. I can attach a afx project if it helps.

    Thanks in advance,
    Brad

    Brad Pickford replied 13 years, 6 months ago 2 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    October 20, 2012 at 3:49 pm

    > I have attached a still image..

    The image seems to be missing.

    Dan

  • Brad Pickford

    October 21, 2012 at 10:57 pm

    Sorry Dan, haven’t uploaded images before, hope this works,
    Cheers

  • Dan Ebberts

    October 22, 2012 at 5:34 am

    I think you’re going to have better luck with something like this:


    r = 239;
    center = thisComp.layer("Object A").transform.position;
    try{
    center + r*normalize(value-center);
    }catch (err){
    value
    }

    Dan

  • Brad Pickford

    October 22, 2012 at 8:11 am

    Hi Dan, thanks for your reply. I have tried your idea. I applied the code to the “Object A” position, but I am still having the same issue of when I drag object along it moves in a decreasing or ascending spiral and doesn’t keep a constant distance radius from the offset Null. I don’t think that I mentioned that “object A” is parented to the Null, would this be causing the issue?

  • Dan Ebberts

    October 22, 2012 at 4:31 pm

    I guess I’m still confused about what you’re trying to do. The expression was for the orbiting object, not “Object A”.

    Dan

  • Brad Pickford

    October 23, 2012 at 10:19 am

    Hi Dan, I have attached a project file that should explain better what I am trying to achieve. Basically The red null is the controller for a characters hand. The Object A is the rotation of the characters hand. I am trying to create animation controls that are all located in the comp window. So when you drag object A in the up and down “Y” position you will see that the layer as it rotates around moves out of orbit and ends up about 100 pixels or more to the bottom of where it started. Basically I want the layer to follow around the red nul in a perfect circle and when it comes back on itself at 360 degrees it will be in the same position as it started. Do you think it will be possible?

    Cheers

    4837_gui.aep.zip

  • Dan Ebberts

    October 23, 2012 at 1:39 pm

    OK – try this. Unparent Object A from the null. Turn off all expressions for the null and the object, and position Object A to the right of the null. Use this for Object A’s position:


    r = 239;
    center = thisComp.layer("Orbvit Centre Null").transform.position;
    try{
    center + r*normalize(value-center);
    }catch (err){
    value
    }

    and this for its rotation:

    r = 239;center = thisComp.layer("Orbvit Centre Null").transform.position;
    try{
    v = transform.position-center;
    radiansToDegrees(Math.atan2(v[1],v[0]));
    }catch (err){
    0
    }

    Then link the null's rotation to that of Object A.

    Something like that.

    Dan

  • Brad Pickford

    October 23, 2012 at 11:49 pm

    Awesome, works well! Thanks again Dan for all your help!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy