Jump to content
Sign in to follow this  
Gabriel Rocha

Clamping to several postions on After effects

Recommended Posts


Is there a way to clamp a X Position opn after effects on several different values?

I've been using this code:





if (transform.xPosition>x1) {




But that only allows me to snap from one position to another. I'd like to be able to snap into 6 positions (on X dimension).

is there a way to do that?

I use the Snaped position to get the position value and use in another layer but i really need to be clamped.




Share this post

Link to post
Share on other sites

assuming the points are equidistant, you can use a floor() function to snap the value to integers instead of floats. Then multiply that result until it's the distances you want. So everytime it "snaps" to the next integer it's jumping to the next placement you want. If your points are not equidistant then I would make an array of all the values you want. Then use the integer snaps (using floor) to trigger the next index value in the array which holds the position you want.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...