FORUMS: list search recent posts

# weird problem with velocity and keyframes on every frame

FAQ   •   VIEW ALL
 weird problem with velocity and keyframes on every frame on Oct 30, 2013 at 8:11:15 pm

I've got a physics simulation made in Newton. For those unfamiliar with Newton, it bakes to keyframes and typically puts one keyframe on every frame for each layer that it animates.

I am trying to set up Trapcode Particular to emit based on the velocity of one of my Newton layers.

I am able to easily acquire the velocity in an expression with position.velocity[0] and position.velocity[1]. I was converting those into absolute values, adding together and then multiplying by a factor to control intensity.

This worked great, and showed up as a nice graph in the graph viewer, when I had the expression results turned on. However, where the graph viewer would show a positive number value for the result of the expression (and a nice squiggly line on my graph), the actual output of the expression would remain at 0. In other words - the graph viewer and the expression output in the property field disagree with each other.

The graph also has a stair step quality to it, which has led me to believe that this is because there is a keyframe on every frame in my source layer, with no space between them. I'm not sure if this is a bug, or an expected behavior.

I was able to work around it by making a null and setting its position to position.smooth of the source layer. Then I pulled the velocity off of that null to drive my other expression. This works fine, but it's clunky.

Any ideas on a more elegant solution?

Thanks!

 Re: weird problem with velocity and keyframes on every frameon Oct 30, 2013 at 11:35:32 pm

what type of keyframe does newton generate?

if it creates hold keyframes or ease keyframes. then to velocity at each keyframe would be 0.

if that's the case, try converting those keyframes to linear (animation>keyframe interpolation, set temporal interpolation to 'linear')

Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW

 Re: weird problem with velocity and keyframes on every frameon Oct 31, 2013 at 2:58:46 am

Curiously, they're just normal linear keyframes.

Here's what it looks like. You can see that the "show post-expression graph" result shows a positive value, yet the property value post-expression is still 0.

In this example I'm just doing a very simple expression to take the velocity of of the first dimension on position and put it on the opacity property

`thisLayer.position.velocity[0]`

 Re: weird problem with velocity and keyframes on every frameon Oct 31, 2013 at 9:23:22 pm

you could try velocityAtTime() to pull the velocity between keys... something like this:

thisLayer.position.velocityAtTime(time-thisComp.frameDuration/2)[0]

the only other thing i can think of is that the velocity is negative, and getting clamped to zero since opacity can't be negative... though the graph doesn't support that.

to test, you could try this:

Math.abs(position.velocity[0])

Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW

 Re: weird problem with velocity and keyframes on every frameon Nov 12, 2013 at 8:00:27 pm

`velocityAtTime(time-thisComp.frameDuration/2)[0]` does the trick!