hello,
i've only been looking in to AE expressions for a few days now, they seem like an extrememlly powerfull thing that i need to learn!
i have no previous java experienceive but have looked at a few tutorials and made a some working expressions, Im am however, having trouble achieving something i'd like... (which is why im posting here obviously... )
in synthesiser terms, I want an LFO/oscilator/sinewave.
is there something that i can use? if so,could you give an example of its use please. for instance how would i use it to modulate the x position of an object.
thanks.
Another noob, another question...
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- Location: London, UK
You could try something like:
Math.sin(time) will create a value that changes between -1 and 1 over time. (time returns the comp time in seconds)
[some value, some value] creates the 2-dimensional array that is required to describe a set of 2D position values.
position + [some value, some value] adds the result of your 2D array to the current 2D values in the position property.
The multiplier (time * 10) makes the sinewave oscillate faster;
The multiplier on the end of Math.sin(time * 10) * 100 scales the resulting Y value offset up from -1>1 to -100>100.
Hope that helps.
Paul T
Code: Select all
position + [0, Math.sin(time * 10) * 100];
[some value, some value] creates the 2-dimensional array that is required to describe a set of 2D position values.
position + [some value, some value] adds the result of your 2D array to the current 2D values in the position property.
The multiplier (time * 10) makes the sinewave oscillate faster;
The multiplier on the end of Math.sin(time * 10) * 100 scales the resulting Y value offset up from -1>1 to -100>100.
Hope that helps.
Paul T
is there a way for me to offset the starting position of the cycle of the sin?
for instance, if i had two objects using the expression given to answer my first question, and i wanted one to go up first then down, and the other to go down first then up.
for instance, if i had two objects using the expression given to answer my first question, and i wanted one to go up first then down, and the other to go down first then up.
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- Location: London, UK
If you consider that time returns a value of 0 on the first frame, it's just a matter of adding an offset to that.
Code: Select all
position + [0, Math.sin((time + 0.3) * 10 ) * 100];