VideoHive

Expressions Question

83 posts
  • Bulgaria
  • Contributed a Blog Post
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Sold between 10 000 and 50 000 dollars
Stefoto says

I was wondering if there is a way to do something that I’m trying to do for a while, but didn’t found the answer.

What I want to do is to take a layer and basically based on the layer index the rotation of the layer to change for example with 5, 10 or whatever amount of degrees I want. I tried the following one: Value + index + 5 for example, but doesn’t work at all :( it takes the index for example 1 and adds 5 to it and it becomes a 6, and when I duplicate the layer the next copy is offset with only 1 degree, because index 2 + 5 is 7 etc.. So I can’t figure out a way to do that. Another thing I was wondering if possible to do is to make a text layer for example and when I duplicate the layer it I want it to offset with a certain amount of degrees that I can change any time in the expression and make the text to display its current degree number.

Hope some of you are better with expressions than me and can help me solve this problem :)

212 posts
  • Sold between 1 000 and 5 000 dollars
  • Exclusive Author
  • Has been a member for 1-2 years
  • Lithuania
  • Referred between 1 and 9 users
  • Contributed a Tutorial to a Tuts+ Site
rendertom says

Regarding your first question try this: (Value + Index) * 5. That way first layer will be (1 + 1) * 5 = 10; seconds layer (1 + 2) * 5 = 15; third (1 + 3) * 5 = 20 etc

Of course your first layer will have 10 instead of 5, so you might do this trick ( Value + (Index - 1)) * 5.

Hope that helps.

Regarding your seconds question, sorry I didn’t get it.

4401 posts
  • Elite Author
  • Community Moderator
  • Sold between 50 000 and 100 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
  • United Kingdom
+5 more
felt_tips moderator says

Multiply!!

On rotation property:
tIncrement = 10; //number of degrees to increment per layer
tIndex = thisLayer.index;
tStartIndex = 5; //the layer index you want to have a rotation of 0
tRotation = (tIndex-tStartIndex)*tIncrement;
On source text property:
thisLayer.text.sourceText = thisLayer.transform.rotation.value.toString() + " degrees";
83 posts
  • Bulgaria
  • Contributed a Blog Post
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Sold between 10 000 and 50 000 dollars
Stefoto says

rendertom thank you very much! This work really well and it is super simple! :)

Regarding my second question. I basically wanted to make the text layer to display the degree number, but after your help I figured out that I can link the source text to the rotation and this way it will display the rotation degree value. Thank you so much for your help!

EDIT :

Thanks felt! Very helpful, a bit more complex than the previous example, but guess more flexible. thanks again for the great help! You’re awesome :)

by
by
by
by
by