How to use timelines to animate variables that aren't "properties"?

Bit of a noob question.

I’ve created a number of scripted effects, internally driven by variables. I’d like to be able to control them – those variables – with timelines.

For example, I’ve made a scripted particle emitter, and in the script there’s a vector emitter_pos that detemines where it emits from. If I want to use a timeline to animate that vector variable, the only way I can see (and that I’m doing at the moment) is to use a timeline to animate another “null” object, and then I read that object’s position every time I update the particles to find out where the emitter should be.

Using a “null” object like this is pretty intuitive for position, but if I’ve got other things I want to control, it starts getting a bit silly - I want to animate a variable that controls how many particles are being emitted, but the only timeline-animatable things I can use are the normal properties an ordinary object has. So I may decide: let’s use the alpha channel of the color property for that. Starts getting a bit crazy having to remember which property controls which, though.

Is this the only way to do this sort of thing, or is there a way I can register a script variable as a property, so it’ll appear in the props pane and can be animated in a timeline?

(I only ask because you can kinda make custom props on subsymbols by right-clicking a prop and choosing “Reference…” which makes that prop appear out in the parent symbol. You can name 'em and all. But you can only promote properties that objects come with out of the box, not create new arbitrary props, as far as I can tell)

I think your best bet would be to use Timeline labels and call those in your script: https://docs.zap.works/studio/workflow/timeline-labels/
they are rather useful

1 Like

You can probably use my timeline class for this, or some other js animation library. Unfortunately, Zapworks doesn’t support this.

1 Like

Wow, that timeline class (and the conversations around it) are fascinating :slight_smile: I’m going to have to have a dig through. Trouble is I’m pretty good at doing similar, if cruder, things with scripts already. I’ve finally sussed how to do audio-sync (which only works reliably if you test Date().getTime() every frame), so I’m triggering a fair bit of stuff depending which beat/bar we’re on. What I really wanted was a visual way to choreograph the overall experience, and at least with timelines you can hit Play and see some sort of representation of what you’ve arranged.

Still, it’s not like I’d be able to see the effects of animated variables going on. So my hack of animating an object I can see on screen, then pulling that channel of data into the script may be the best approach for now.

From the other convos you linked:

Feeling quite smug that I’d independently sussed using RelativeToProp as a way of using timelines to animate between scriptable positions; certainly helps until we can access the keyframes directly. Kinda frustrating seeing the data you want to play with but not being able to touch it:

23

Still, only a matter of time I hope: giving devs access to granular stuff like this has the potential to break things in so many ways that Zap’s support team would be flattened, so it’ll probably need to be wrapped in friendly APIs and richly documented before they could open the door to us :slight_smile:

Spking of docs - it’s interesting to see others wondering what on earth that enqueue() thing is all about … it’s all very intriguing

1 Like

I already created a forum post in the feature requests section but sadly it didn’t get any traction. It doesn’t seem like many people care about this feature, other than you and me lol. But you should probably leave a comment there to endorse the idea.

1 Like