so I have a playable director that is NOT set to “play on awake” but rather played using .play() when the player enters a trigger.
The problem I am having is that when the .play() function is called, there is a significant drop in fps. from 60fps to almost 30fps only fro a split second.
The profiler shows me that there is some garbage allocation happening under PlayableAsset.Internal_CreatePlayable() - there are 80 calls to GCAlloc and this seems to be the culprit.
The playable consists of a model moving location and rotation and uses a walking animation. it only lasts for a few seconds so its not big in any way.
Is anyone able to explain this to me or how it works because I’m confused as to how something so simple can have such an effect on the fps.
When you hit plays it takes the model of the timeline (ScriptableObjects) and compiles a Playable Graph representing the timeline - effective an instance of the timeline. There are allocations that occur during that process.
You can compile the graph without playing it by calling RebuildGraph on the PlayableDirector - for example from an Awake call. That will eliminate the allocations when you call Play on the graph.
Is there an example of how to use this somewhere? google hasn’t given me any useful results. Or is it as simple as calling it (e.g playable.rebuildgraph()) in the awake function?