When using DropListener, is it possible to load multiple animations from the file and play them all?

E.g. a model of an avatar who has a sign that swings next to him, both separate objects in the glb with separate animations. I’m going to try to do this myself tomorrow but wondered if it would be good to play all anims by default too

Original Post on Discord

by user 103054507105067008

Can you clarify “play them all”? There is multiple cases:

  • animations could target the same objects, so playing them back at the same time would cause overlaps
  • animations can be independent, in that case you could all play them back

But the answer is “generally yes”, you are able to play them all back, just be careful with models where animations might overlap.

I’ll sort out the targeting of the animations myself, I can see why playing them all back could cause issues

by user 103054507105067008

Is it safe to edit engine_networking_files_default_components.ts myself or will that get overwritten between updates? I want to customise the below lines to load and assign animations. If I try getting the animations list from the object after it has spawned using the ObjectAdded event on DropListener.ts, I only get 1 animation there but if I read the animations in engine_netwroking… before spawn, I get all the animations in the file

    if (gltf) {
        if (gltf.animations?.length > 0) {
            const firstAnimation = gltf.animations[0];
            const anim = GameObject.addNewComponent(obj, Animation, false);
            anim.animations = [firstAnimation];

by user 103054507105067008

An overridefor onDynamicObjectAdded would be most useful for this as I implemented a fix for what we need locally but it’s in the engine .ts files

by user 103054507105067008

No, please don’t modify core files - you should always use proper callbacks. Changes to those will be gone same as with immutable packages from Unity’s registry and so on.

If there are missing ones, let us know and we can add them, but I think the one Marcel added for the drop listeners should expose all loaded data (including loaded animations) already.

In the droplistener callback I only get 1 animation returned when reading it, its in the commented out region here, I only get one animation when reading the args.detail but maybe I need to grab it as args.gltf to get the root file animations? See commented out region

by user 103054507105067008

can you drop me the glb file?

Will privately wetransfer, local amended engine_networking file here too which works for our needs to play back both animations via the object name matching part of the animation name strings

by user 103054507105067008

I thought I did change that to return the whole gltf in the event :thinking: strange