Search Unity

Bug Exception in GhostAnimationControllerInterpolationSystem

Discussion in 'NetCode for ECS' started by Richay, Jan 31, 2024.

  1. Richay

    Richay

    Joined:
    Aug 5, 2013
    Posts:
    122
    So I ran into a fun(tm) problem where my client prefab was instantiated into a scene, and then the scene was unloaded. This had the knock-on effect of causing exception spam from
    GhostAnimationControllerInterpolationSystem
    .

    Code (CSharp):
    1. var go = m_GhostPresentationGameObjectSystem.GetGameObjectForEntity(EntityManager, entity);
    2. var ctrl = go?.GetComponent<GhostAnimationController>();
    3. if (ctrl != null)
    4.     ctrl.CopyFromEntities();
    The
    go?.GetComponent
    was throwing an
    ObjectAlreadyDestroyed
    (or something) exception. Usually, Visual Studio warns against using the
    ?.
    operator on Unity objects, specifically to avoid this situation.

    On this note, it would be nice if that system didn't run if there were no gameobjects with the
    GhostAnimationController
    component.
     
  2. Richay

    Richay

    Joined:
    Aug 5, 2013
    Posts:
    122
  3. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    Yup, thanks for reporting!
     
    Richay likes this.