Should You Continue Using Timeline for Combat Skills with Dynamic Effects and Targets in Unity?
A project uses Timeline to sequence character skill effects, audio, and playback order, but the effects’ start and end positions must also be calculated dynamically based on enemy positions. When many units attack simultaneously, 28 Timeline related calls occur in a single frame. Is Timeline still suitable for these combat skills?
Should You Continue Using Timeline for Combat Skills with Dynamic Effects and Targets in Unity? Q1: A project uses Timeline to sequence character skill effects, audio, and playback order, but the effects’ start and end positions must also be calculated dynamically based on enemy positions. When many units attack simultaneously, 28 Timeline related calls occur in a single frame. Is Timeline still suitable for these combat skills? A: Timeline can still be used, but it is recommended to handle skill presentation sequencing only, while the skill system remains responsible for dynamic targets and combat logic. Timeline is well suited to organizing animations, visual effects, and audio with relatively fixed playback sequences. However, target selection, start and end positions, projectile trajectories, and hit detection change dynamically with combat state. If all of these responsibilities are handled by Timeline, combat data must be continuously passed to and bound to the playback system at runtime, increasing coupling between the presentation layer and combat logic. The 28 Timeline related calls in a single frame indicate that a substantial amount of Timeline related work is concentrated when many units release skills simultaneously. However, the call count alone does not prove that Timeline has become a performance bottleneck. Inspect the call stacks to determine whether these calls primarily occur during Playable or PlayableGraph creation, data binding, or Graph evaluation . Also, examine both the individual call durations and the total time spent in these operations. https://uwa overseas public.oss us east 1.aliyuncs.com/uploads/markdown/3ae3b46b b9ee 45c8 a3f2 64be501c624c.png The recommended approach is to separate responsibilities as follows: Skill System Handles skill activation timing, target selection, start and end positions, projectile trajectories, and hit detection. Presentation Module Plays visual effects, animations, and audio according to the timing and data provided by the skill system. Timeline Remains responsible for complete sequences with relatively fixed playback content and low trigger frequency, such as story sequences, boss entrances, and character cut ins. There is no need to refactor the entire project at once. Start by adjusting normal attacks or frequently triggered minor skills. Under the same device, unit count, and combat sequence, compare the number of Timeline related calls, logic execution time, and frame rate before and after the change. If both the call count and CPU time decrease, the separation is effective, and the adjustment can be extended to more skills. If the call count decreases but overall CPU time and frame rate remain largely unchanged, Timeline is unlikely to be the primary bottleneck. Continue investigating other CPU hotspots based on the call stacks.