egametang/ET · error · Exception

动作播放失败: {self.MotionType}

Error message

动作播放失败: {self.MotionType}

What it means

Thrown by AnimatorComponentSystem (mapplay package) when calling Unity's Animator.SetTrigger or Animator.SetFloat fails inside a try-catch. The trigger name is self.MotionType.ToString(), so the most common cause is that the AnimatorController does not have a trigger parameter matching the MotionType enum name. The inner exception is preserved. This is a near-identical duplicate of the lockstep LSAnimatorComponent implementation.

Source

Thrown at Packages/cn.etetet.mapplay/Scripts/HotfixView/Client/Unit/AnimatorComponentSystem.cs:71

			}

			if (self.MotionType == MotionType.None)
			{
				return;
			}

			try
			{
				self.Animator.SetFloat("MotionSpeed", self.MontionSpeed);

				self.Animator.SetTrigger(self.MotionType.ToString());

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

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

		public static void PlayInTime(this AnimatorComponent 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)

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Open the AnimatorController asset and add a trigger parameter named exactly after the MotionType enum value shown in the error.
  2. Ensure the Animator component is assigned and active on the GameObject at call time.
  3. Check HasParameter(motionType.ToString()) before calling SetTrigger to guard against unconfigured states.

Example fix

// before
self.Animator.SetTrigger(self.MotionType.ToString());
// after: guard with HasParameter
string triggerName = self.MotionType.ToString();
if (self.HasParameter(triggerName))
{
    self.Animator.SetTrigger(triggerName);
}
else
{
    Log.Warning($"Animator missing trigger: {triggerName}");
}
Defensive patterns

Strategy: validation

Validate before calling

// Guard before triggering animation
string triggerName = self.MotionType.ToString();
if (self.Animator == null) { Log.Error("Animator is null"); return; }
if (!self.HasParameter(triggerName)) { Log.Warning($"Animator missing trigger: {triggerName}"); return; }

Prevention

When it happens

Trigger: PlayInTime or a direct animation call sets self.MotionType to a value whose ToString() does not correspond to any trigger parameter in the AnimatorController asset. Or the Animator component is null/destroyed at call time.

Common situations: A new MotionType enum value was added but the AnimatorController asset was not updated with the matching trigger. AnimatorController was swapped or missing from the prefab. Animator component was not assigned or was destroyed before the call.

Related errors


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