Is there a way to activate/deactive sin wave in hscript?

   5864   9   2
User Avatar
Member
55 posts
Joined: July 2005
Offline
Is there a way to activate/deactive sin wave in hscript? For example, I inserted sin($F * 20) in my translate X but I don't want it to keep moving constantly…. I would like it to start the shake at frame 10 and lasts for 10 frame and easeout and stop…. Is it possible?
User Avatar
Member
182 posts
Joined: April 2009
Offline
Just create a new spare parameter via “Edit Parameter Interface” ( let's call it “mult” ) and multiply your values with that. So your expression will look like this: sin($F * 20) * ch( “mult” ). Then you can animate the multiplier and let it fade out. While you're at it you could also substitute the “20” with a speed parameter 8)
Edited by - July 28, 2015 08:42:25

Attachments:
shake_it.hip (48.7 KB)

User Avatar
Member
182 posts
Joined: April 2009
Offline
If you're looking for a solution via expressions only,
then you can use fit() inside an if() statement:

if( $FF > ch(“start”), fit( $FF, ch(“end”), ch(“end”) + ch(“fade”), sin( $FF * 100 ), 0 ), 0 )

where “start” and “end” is your shake frame range and “fade” is the fade out length.

Attachments:
shake_it_expression.hip (48.5 KB)

User Avatar
Member
182 posts
Joined: April 2009
Offline
To make things worse for the eye, here's a version with fade in and fade out
fit($FF,ch(“start”),ch(“start”)+ch(“fadeIn”),0,fit($FF,ch(“end”),ch(“end”)+ch(“fadeOut”),sin($FF*100),0))

Attachments:
shake_it_expression_2.hip (48.7 KB)

User Avatar
Member
55 posts
Joined: July 2005
Offline
Hahaha, blackpixel, you cracked me up after another long and stupid day! Amazed that you can play that far with the basic sin expression, sooo cool!

I have done some search earlier but only found the camera shake tips at Setting up Cameras page if($F%2, 1, -1) * easeout()

But not sure why it only works with camera cry Anyway, I like yours better, so much more control, thanks again!
User Avatar
Member
8785 posts
Joined: July 2007
Offline
davidave
…But not sure why it only works with camera :cry: …

it works with any channel
you can as well set following for the full time segment:
sin($FF*100)*bezier()

then still adjust bezier values and handles in animation editor while the result will be multiplied by the sin()
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
55 posts
Joined: July 2005
Offline
So adding a sin() on top of keyed animation, never realized that can done!!!!
Thanks for the tip, Tomas!
User Avatar
Member
8785 posts
Joined: July 2007
Offline
davidave
So adding a sin() on top of keyed animation, never realized that can done!!!!
Thanks for the tip, Tomas!
while you can do that be aware that the expressions are set for channel segments, so from current to next keyframe
so if you do sin($FF*100)*bezier() and place several more keyframes and adjust the bezier, the expression on each would be unique, meaning that if you then change it to sin($FF*10)*bezier() it would change the expression only for current segment and not for others, making it slightly more tricky to mantain continuity and keep it transparent
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
319 posts
Joined:
Offline
Mind blown!

Did not know you could do that! I've always done that kind of thing by creating a spare parameter and putting my multiply curve in there and then doing:-

sin($FF*20) * ch(“parm”)

This new way I get to see a cool sin curve being multiplied down to nothing in the channel view.

Sweet!!
User Avatar
Member
319 posts
Joined:
Offline
Just realised you also get that view when multing by a spare parameter. 8)

Still cool though.
  • Quick Links