FyroxEngine/Fyrox · warning
err.to_string()
Error message
err.to_string()
What it means
In TileMapCollidersSource::get_terrain, resolving the tile pattern at a position failed; the error is logged verbatim (err.to_string()) and None is returned for the terrain id. It indicates a position lookup failure in the autotiling pattern grid (e.g. out-of-bounds coordinates).
Solutions
- Validate that the position lies within the tile map bounds before calling get_terrain.
- Handle the Option::None return in caller code as 'no terrain' rather than assuming a valid id.
- Ensure the colliders source is synchronized with the current tile map size.
- Read the logged err message for the precise reason (usually out-of-bounds) reported by pattern_at.
Example fix
// before
let terrain = colliders.get_terrain(&pos).unwrap();
// after
if let Some(terrain) = colliders.get_terrain(&pos) {
// use terrain
} Defensive patterns
Strategy: fallback
Validate before calling
let in_bounds = pos.x >= 0 && pos.y >= 0;
if !in_bounds { /* skip query */ } Try / catch
// get_terrain logs and returns None on failure
match colliders.get_terrain(&pos) {
Some(t) => use_terrain(t),
None => Log::warn(format!("no terrain at {pos}, treating as empty")),
} Prevention
- Bounds-check positions before querying autotile data.
- Refresh colliders data after tile map resizes.
- Never unwrap the returned Option.
When it happens
Trigger: Calling get_terrain with a Vector2<i32> position for which pattern_at returns Err — typically a position outside the collider grid bounds.
Common situations: Querying tile data at coordinates beyond the tile map bounds; iterating neighbors of edge/corner tiles without bounds checks; stale colliders data after map resize.
Related errors
- Failed to load brush tool data due to
- Tile set load failed! Reason
- Tile set load failed!
- Tile set update page missing.
- Graphics context is uninitialized!
AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10).
Data as JSON: /api/errors/ab266c1cc2fd7e9d.
Report an issue: GitHub.
Appendix: source
Thrown at fyrox-impl/src/scene/tilemap/autotile.rs:381
else {
return Ok(PatternBits::default());
};
self.property_id
.get_from_tile_set(self.tile_set, element.handle)
.map(|v| v.into())
}
}
impl PatternSource for TileSetPatternSource<'_, '_, '_> {
type Position = Vector2<i32>;
type Terrain = TileTerrainId;
type Pattern = PatternBits;
fn get_terrain(&self, position: &Vector2<i32>) -> Option<TileTerrainId> {
match self.pattern_at(position) {
Ok(pattern) => Some(pattern.center()),
Err(err) => {
Log::err(err.to_string());
None
}
}
}
/// The constraint for the cell at the given position.
fn get(&self, position: &Vector2<i32>) -> TileConstraint<TileTerrainId, PatternBits> {
match self.pattern_at(position) {
Ok(pattern) => TileConstraint::Pattern(pattern),
Err(err) => {
Log::err(err.to_string());
TileConstraint::None
}
}
}
}
/// Wave function collapse propagator for the tiles of a [`TileSet`] that uses
/// the nine-slice values of one of the tile set's properties as the wave function'sView on GitHub (pinned to 76c91aad8e)