EllanJiang/GameFramework · error · GameFrameworkException
Already exist FSM ' '.
Error message
Already exist FSM '{0}'. What it means
CreateFsm<T>(name, owner, params FsmState<T>[]) registers a new FSM keyed by (owner type, name). If an FSM with the same owner type and name already exists, the library throws to prevent silently overwriting an existing FSM in the m_Fsms dictionary.
Solutions
- Check HasFsm<T>(name) before creating and reuse the existing FSM via GetFsm<T>(name)
- Destroy the existing FSM first with DestroyFsm<T>(name) if re-creation is intended
- Ensure initialization code runs only once (guard flag or singleton pattern)
Example fix
// before
fsmManager.CreateFsm(player, "movement", states); // throws on second call
// after
if (!fsmManager.HasFsm<Player>("movement"))
{
fsmManager.CreateFsm(player, "movement", states);
}
else
{
movementFsm = fsmManager.GetFsm<Player>("movement");
} Defensive patterns
Strategy: validation
Validate before calling
if (fsmManager.HasFsm<Player>("movement"))
movementFsm = fsmManager.GetFsm<Player>("movement");
else
movementFsm = fsmManager.CreateFsm(player, "movement", states); Try / catch
try { movementFsm = fsmManager.CreateFsm(player, "movement", states); }
catch (GameFrameworkException ex) { movementFsm = fsmManager.GetFsm<Player>("movement"); } Prevention
- Gate FSM creation behind a singleton/init-once flag
- Always pair CreateFsm with a HasFsm check
- Clean up FSMs on scene unload (DestroyFsm) to avoid stale registrations
When it happens
Trigger: Calling CreateFsm<T> with a name that already maps to an existing FSM for type T — HasFsm<T>(name) returns true before Fsm<T>.Create is attempted.
Common situations: Calling CreateFsm twice during initialization (e.g. in both Awake and Start in Unity); restarting a scene without destroying FSMs; duplicate FSM names in a config-driven setup; hot-reload re-running registration code.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- FSM ' ' state ' ' is already exist.
- Already exist ' ' in data table ' '.
- FSM owner is invalid.
- FSM states is invalid.
- FSM is running, can not start again.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/214ee958f852b8cd.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Fsm/FsmManager.cs:259
public IFsm<T> CreateFsm<T>(T owner, params FsmState<T>[] states) where T : class
{
return CreateFsm(string.Empty, owner, states);
}
/// <summary>
/// 创建有限状态机。
/// </summary>
/// <typeparam name="T">有限状态机持有者类型。</typeparam>
/// <param name="name">有限状态机名称。</param>
/// <param name="owner">有限状态机持有者。</param>
/// <param name="states">有限状态机状态集合。</param>
/// <returns>要创建的有限状态机。</returns>
public IFsm<T> CreateFsm<T>(string name, T owner, params FsmState<T>[] states) where T : class
{
TypeNamePair typeNamePair = new TypeNamePair(typeof(T), name);
if (HasFsm<T>(name))
{
throw new GameFrameworkException(Utility.Text.Format("Already exist FSM '{0}'.", typeNamePair));
}
Fsm<T> fsm = Fsm<T>.Create(name, owner, states);
m_Fsms.Add(typeNamePair, fsm);
return fsm;
}
/// <summary>
/// 创建有限状态机。
/// </summary>
/// <typeparam name="T">有限状态机持有者类型。</typeparam>
/// <param name="owner">有限状态机持有者。</param>
/// <param name="states">有限状态机状态集合。</param>
/// <returns>要创建的有限状态机。</returns>
public IFsm<T> CreateFsm<T>(T owner, List<FsmState<T>> states) where T : class
{
return CreateFsm(string.Empty, owner, states);
}View on GitHub (pinned to d0c010b051)