Binding ScriptableObject to track

For context, the system I want to make is one that creates/destroys entities and assigns their behaviours on a scripted basis. I would have a scriptableObject bound to a track that defines the parameters of the entity to spawn, and the clips on the track would be commands. References to the instantiated objects would be determined by indexing into a dictionary. The reason I want to do it in this roundabout way is so that the timeline can assign AI behaviour to entities across scenes (and also be able to dynamically handle creation/destruction of said entities). A general idea of what I want to do can be seen in the image I attached.

As far as I can tell using scriptableObjects isn’t the intended use of the binding, but the track binding simply takes a Unity Object, and the processframe functions pass an object for data where it’s up to me to process it, so it should work in theory.

I have a couple questions/issues though:

I want to use Markers to spawn/despawn the entity for that track, with info on how to spawn/despawn them as data on the markers. The issue is that I can’t add any Markers that implement INotification to the track even when the SO implements the receiver interface. I’m assuming this is because the timeline is look for a component on the object with the interface, as opposed to the object itself. Obviously scriptableObjects have no components, so it won’t allow any markers to be placed on the track. The same applies for signals.

I could attach the scriptableObject to the track itself, and bind the created gameobject at runtime when it’s spawned. I would now have a gameobject bound to the track, so it could receive notifications. But this only works after it has been spawned, which won’t work for the ‘create’ marker.

Other potential solutions would be using the timeline markers instead of track markers and have the director gameobject handle it, but it would easily get messy and confusing as to which marker corresponds to which track.

Another solution would be just use a very quick clip to spawn/despawn it, which would work, but it isn’t as clean or user-friendly of a solution as using markers which overlay nicely on top of the track and could have user-defined images for spawn/despawn markers.

I understand this is a pretty niche application of the timeline system. The vast majority of cases you could just bind directly from the scene.

I’m just wondering if there would either be more support for binding scriptableobjects (ability to use Markers on scriptableObject bound tracks), or some way that I could use track Markers before a gameObject is bound to the track (rather, specifically in order to bind an object to the track).

We definitively wrote the notification system with the assumption that everything it would bind to would be GameObject-based. Maybe it’s possible to make it work for ScriptableObject, maybe it’s not, but either way, it’s unlikely to be something that we backport. I will add it to our list of potential improvements, but it might well not come in time for your personal use case.

Using a ScriptableObject is a clever idea, but I’m not sure I understand why your spawner object receiving commands can’t be a GameObject? If it’s a question of managing the lifetime of that object, you should be authoring your Timeline in a prefab so you always know that the object will be there.

Also, If you want your system to be reliable, then you definitely should use markers for spawning events, because otherwise you risk skipping over a spawn event if there is a large enough frame drop. As a general rule, things that must happen should be done using notifications, and clips should be used to provide the state at the current time.

I figured as much for the notifications

The reason why I looked to scriptableobject instead of binding a known gameobject directly was because I want to have different timelines be able to command the same entities.

So for example, timeline 1 hits create marker and spawns and commands an entity for a while, then timeline 2 hits a create command for that same entity and steals control away from timeline 1 before the despawn marker was reached. Only one timeline can command an entity at once.

I was looking to dynamically spawn the entities in a don’t unload scene separate from level geometry so that the timelines could do somewhat of a relay across scenes, passing control of entities to one another, only despawning the entity if another timeline hasn’t picked up the relay so to speak. (Scene where that entity is going to isn’t loaded. Timeline is checked to find where they should be on scene load.)

Pre-binding gameobjects would have trouble with the relay I’m looking to pull off. That said a potential solution could just be storing the entity in the scene they’re in and the scene they’re going to and just copying over values and doing an enable-disable switcheroo to have the appearance of being seamless.

Might also just use global markers even though it won’t be as clean. Just kind of unfortunate that only the gameobject on the track itself can receive the event from a track marker.

Hey, thanks for reporting this.

I think it should be relatively easy to fix.

Could you report a bug with your data?

Is this still broken, or has it been fixed?