Skip to main content
Tolomuco-Daniel
Participating Frequently
May 10, 2024
Answered

I have t

I have to update a project made by another workmate, he is not available, he have this character hair bouncing a bit when it moves the head and the hair have this expression and show me this error

 

and this is the expression

freq = 3;
decay = 5;
n = 0;
if (numKeys > 0){
 n = nearestKey(time).index;
 if (key(n).time > time) n--;
}
if (n > 0){
 t = time - key(n).time;
 amp = velocityAtTime(key(n).time - .001);
 w = freq*Math.PI*2;
value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else
 value
freq = 0.2;
amp = 80;
s= amp*Math.sin(freq*time*2*Math.PI);
[s,s];

This topic is closed to new replies. Start a new post to keep the conversation going.
Dan Ebberts
Dan EbbertsCorrect answer
Community Expert
May 11, 2024

Depending on how you have your keyframes set up, this might be more what you're looking for:

freq = 3;
decay = 5;
n = 0;
if (numKeys > 0){
 n = nearestKey(time).index;
 if (key(n).time > time) n--;
}
if (n > 0){
  t = time - key(n).time;
  amp = speedAtTime(key(n).time - .001);
  w = freq*Math.PI*2;
  value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else
  value

8 replies

Tolomuco-Daniel
Participating Frequently
May 10, 2024

@Mylenium and @Dan Ebberts Thanks both of you. I'm still struggling learning expressions. both solutions work to eliminate the error, but both solutions set and awkard angle in the layer I can't change, the hair ends almos vertical hidden behind the character head.

Translate
Dan Ebberts
Community Expert
Community Expert
May 10, 2024

Actually, looking at it a little closer, it looks like this expression started out as one thing and has been modified, inconsistently, a time or two so that it's hard to say what the original intention was. How do you want it to work?

Translate
Tolomuco-Daniel
Participating Frequently
May 10, 2024

The top piece of hair is anchored on one side of the head, bounce a bit with the head movements, but actually is a very subtle movement... So I render it without it to meet the time, client don't even notice it, but I get intrigued on how it was made and how to fix it. I have a few rotation keyframes on the movement and the expression it's supposed to help make ot more bouncy... sadly I can share the project 'cause. any of idea?? may be a completely diff expression?

Translate
Dan Ebberts
Community Expert
Community Expert
May 10, 2024

It looks like that's a scale expression. It should work for rotation if you replace the last two lines with this one:

amp*Math.sin(freq*time*2*Math.PI)
Translate
Mylenium
Legend
May 10, 2024

Fix the last line to only be [s].

 

Mylenium

Translate