Fire an Event when an Anim State changes? Better way to automate camera movement?

I am attempting to code a system where a camera moves automatically through a scene on a preset route, with “stops” at predefined points. I’m using the names 1,2,3,4,5 for the stops which are “animations” with a single keyframe, and names akin to “1to2” for animations that transition between 1 and 2 with keyframes at start and end.

So far this has been accomplished by creating the animation in blender by moving the camera object. However, I need to know when the animation state changes, or when a state finishes, but i can’t see a way of doing that short of manually adding an event on every animation asset with the duration of it as the trigger time.

The issue is this project is still in flux and if we re-import the camera and animation assets, I need to redo the entire state graph and events.

Is there an event that already fires that I’m unaware of? or is there a way fir me to programmatically go through the camera’s animation states and grab their duration, and add an event to the animation assets that fires at duration time?

I’m also open to better ways to automate camera movement, as this would seem a very standard thing for a cutscene, and while i’m not doing a cutscene, it’s a good close analogy for what I’m trying to achieve: camera moves, wait for input, camera moves to next spot, repeat.

Hi @Keith-Impromptu and welcome,

Regarding your question on getting the animation states, I’m not sure if this has been fully exposed as a public API (@Elliott?). There is a similar discussion here:

Feature request: [API Enhacement Request] Expose additional information to the AnimComponent and AnimComponentLayer APIs · Issue #3688 · playcanvas/engine · GitHub

at least I’m not the only one wanting this functionality. It would seem to be a desirable feature.

The other annoyance is that a re-import requires a full reconnection of all the assets, when we’d really want to replace the template and assets from blender.

I’m simply trying to make our development flow less tortuous

1 Like