Skip to content

LDtk example #73

@SueHeir

Description

@SueHeir

Hello! I am trying to implement a flowfield from data from the LDtk tiled plugin, and I think I'm getting very confused about the origin/grid system.

the size of the map is a square with 512 pixels.

Right now I have GridCoords for each tile that needs its cost value set to 255. But I am getting the following error. Is get_sector_and_field_cell not using world coords for its input?

let mut flow_field = FlowFieldTilesBundle::new(width as u32 * grid_size as u32, height as u32 * grid_size as u32, width as u32 *grid_size as u32, 10.0);


for level_wall in level_walls {

    let x =  (grid_size as f32 * level_wall.x as f32);
    let y =  (grid_size as f32 * level_wall.y as f32);
    
    if let Some((sector_id, field_cell)) = flow_field.map_dimensions.get_sector_and_field_cell_from_xy(Vec2::new(x, y)) {
        flow_field.sector_cost_fields.set_field_cell_value(sector_id, 255, field_cell, &flow_field.map_dimensions);
    }
}
2025-02-11T05:38:52.153072Z ERROR bevy_flowfield_tiles_plugin::flowfields::sectors: Position is out of bounds of MapDimensions, x 464, y 112, cannot calculate SectorID. Is the actor outside of the map or trying to request route outside of it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions