Skip to content

Commit b0e8b2f

Browse files
committed
Implement animation speed multiplier
1 parent 8b4ba26 commit b0e8b2f

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

Diff for: DOTS.Animation.Hybrid/Baking/AnimationBakingSystem.cs

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public override void Bake(AnimationsAuthoring authoring)
137137
InTransition = false,
138138
TransitionDuration = 0,
139139
TransitionElapsed = 0,
140+
SpeedMultiplier = 1,
140141
});
141142

142143
AddComponent(new CurrentClip()

Diff for: DOTS.Animation/AnimationAspect.cs

+5
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,10 @@ public void Pause()
4949
{
5050
AnimationPlayer.ValueRW.Playing = false;
5151
}
52+
53+
public void SetSpeedMultiplier(float speedMultiplier)
54+
{
55+
AnimationPlayer.ValueRW.SpeedMultiplier = speedMultiplier;
56+
}
5257
}
5358
}

Diff for: DOTS.Animation/AnimationComponents.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public struct AnimationPlayer : IComponentData
1111

1212
public float TransitionDuration;
1313
public float TransitionElapsed;
14+
15+
public float SpeedMultiplier;
1416
}
1517

1618
public struct CurrentClip : IComponentData
@@ -75,4 +77,4 @@ public struct AnimatedEntityRootTag: IComponentData
7577

7678

7779

78-
}
80+
}

Diff for: DOTS.Animation/PlayAnimationSystem.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ public void Execute(ref AnimationPlayer animationPlayer, ref CurrentClip current
209209
{
210210
if (!animationPlayer.Playing) return;
211211
// Update elapsed time
212-
currentClip.Elapsed += DT * currentClip.Speed;
213-
nextClip.Elapsed += DT * nextClip.Speed;
212+
currentClip.Elapsed += DT * currentClip.Speed * animationPlayer.SpeedMultiplier;
213+
nextClip.Elapsed += DT * nextClip.Speed * animationPlayer.SpeedMultiplier;
214214

215215
if (currentClip.Loop)
216216
{
@@ -247,4 +247,4 @@ public void Execute(ref AnimationPlayer animationPlayer, ref CurrentClip current
247247
}
248248
}
249249
}
250-
}
250+
}

0 commit comments

Comments
 (0)