egametang/ET · error · Exception

找不到该动作: {motionType}

Error message

找不到该动作: {motionType}

What it means

Thrown by LSAnimatorComponentSystem.PlayInTime when the requested MotionType does not have a corresponding AnimationClip in self.animationClips. The dictionary is keyed by MotionType.ToString(), so a missing entry means the clip was never registered for that motion type. The animation cannot be played in the specified time without knowing its length.

Source

Thrown at Packages/cn.etetet.lockstep/Scripts/HotfixView/Client/LSAnimatorComponentSystem.cs:86

				self.MotionType = MotionType.None;
			}
			catch (Exception ex)
			{
				throw new Exception($"动作播放失败: {self.MotionType}", ex);
			}
		}

		public static bool HasParameter(this LSAnimatorComponent self, string parameter)
		{
			return self.Parameter.Contains(parameter);
		}

		public static void PlayInTime(this LSAnimatorComponent self, MotionType motionType, float time)
		{
			AnimationClip animationClip;
			if (!self.animationClips.TryGetValue(motionType.ToString(), out animationClip))
			{
				throw new Exception($"找不到该动作: {motionType}");
			}

			float motionSpeed = animationClip.length / time;
			if (motionSpeed < 0.01f || motionSpeed > 1000f)
			{
				Log.Error($"motionSpeed数值异常, {motionSpeed}, 此动作跳过");
				return;
			}
			self.MotionType = motionType;
			self.MontionSpeed = motionSpeed;
		}

		public static void Play(this LSAnimatorComponent self, MotionType motionType, float motionSpeed = 1f)
		{
			if (!self.HasParameter(motionType.ToString()))
			{
				return;
			}

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Add an AnimationClip for the missing MotionType in the component's initialization so it populates animationClips.
  2. Check the clip name matches the MotionType enum value exactly (the dictionary key is MotionType.ToString()).
  3. Verify the Animator has the clip assigned and the component's clip-scanning logic runs before PlayInTime is called.

Example fix

// before
public static void PlayInTime(this LSAnimatorComponent self, MotionType motionType, float time)
{
    if (!self.animationClips.TryGetValue(motionType.ToString(), out animationClip))
        throw new Exception($"找不到该动作: {motionType}");
}
// after: guard and log
if (!self.animationClips.TryGetValue(motionType.ToString(), out animationClip))
{
    Log.Warning($"missing animation clip: {motionType}, skipping PlayInTime");
    return;
}
Defensive patterns

Strategy: validation

Validate before calling

// Guard before calling PlayInTime
if (!self.animationClips.ContainsKey(motionType.ToString()))
{
    Log.Warning($"No AnimationClip registered for {motionType}, cannot compute PlayInTime");
    return;
}

Prevention

When it happens

Trigger: PlayInTime is called with a MotionType that was not added to the animationClips dictionary during initialization (Awake/Init). This dictionary is typically populated by scanning the Animator's clips or by explicit registration.

Common situations: A new MotionType enum value was added but no AnimationClip was assigned in the prefab/inspector. The animationClips dictionary initialization did not scan all clips (e.g. clips added after Awake). PlayInTime is called before the component finished initializing its clips.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/a2b86a75a63125d1. Report an issue: GitHub.