stride3d/stride · error · InvalidOperationException
Duplicate collider added
Error message
Duplicate collider added
What it means
NavigationMeshBuilder.Add registers a static collider for navmesh building, keyed by the component's Id. Throwing InvalidOperationException prevents the same collider component from being added twice, which would produce duplicated geometry in the built navmesh.
Solutions
- Guard with a membership check before adding, or track your own registration state per component
- Ensure the corresponding Remove is called when the component is deactivated/removed before re-adding
- Fix duplicate event subscription so registration happens exactly once per component lifetime
Example fix
// before
builder.Add(colliderData); // may already be registered
// after
if (!builderIsRegistered(colliderData.Component.Id))
builder.Add(colliderData); Defensive patterns
Strategy: validation
Validate before calling
// track registration yourself var registeredIds = new HashSet<Guid>(); if (registeredIds.Contains(colliderData.Component.Id)) return; // already added builder.Add(colliderData); registeredIds.Add(colliderData.Component.Id);
Type guard
null
Try / catch
try
{
builder.Add(colliderData);
}
catch (InvalidOperationException)
{
// duplicate registration; safe to ignore or log
} Prevention
- Pair every Add with exactly one Remove in the component lifecycle
- Avoid duplicate subscriptions to entity/scene events
- Idempotent registration guards (check-then-add) in re-init paths
When it happens
Trigger: Calling Add(StaticColliderData) twice for a component with the same Id — e.g. re-registering on scene reload, double entity initialization, or a component's registration event firing more than once.
Common situations: Scene hot-reload or script restart where cleanup (Remove) was skipped; duplicate event subscriptions (Added event firing twice); manually adding colliders that the system already registered automatically.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- gameSettings
- Trying to remove unregistered collider
- does not consist of triangles
- A routed event named
- The upgrader overlaps with another upgrader.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/fafc485e4667c4a2.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Navigation/NavigationMeshBuilder.cs:57
public NavigationMeshBuilder(NavigationMesh oldNavigationMesh = null)
{
this.oldNavigationMesh = oldNavigationMesh;
}
/// <summary>
/// Adds information about a collider to this builder
/// </summary>
/// <remarks>
/// You can only register a single <see cref="StaticColliderComponent"/> once
/// </remarks>
/// <exception cref="InvalidOperationException">When trying to register collider data with the same <see cref="StaticColliderComponent"/> twice</exception>
/// <param name="colliderData">A collider data object to add</param>
public void Add(StaticColliderData colliderData)
{
lock (colliders)
{
if (registeredGuids.Contains(colliderData.Component.Id))
throw new InvalidOperationException("Duplicate collider added");
colliders.Add(colliderData);
registeredGuids.Add(colliderData.Component.Id);
}
}
/// <summary>
/// Removes a specific collider from the builder
/// </summary>
/// <param name="colliderData">The collider data object to remove</param>
public void Remove(StaticColliderData colliderData)
{
lock (colliders)
{
if (!registeredGuids.Contains(colliderData.Component.Id))
throw new InvalidOperationException("Trying to remove unregistered collider");
colliders.Remove(colliderData);
registeredGuids.Remove(colliderData.Component.Id);
}View on GitHub (pinned to 96fad776d2)