I’m making a simple platformer with a tilemap-based world. My levels are laid out like so:
For every wall block, I create a Cuboid
shape and attach it to the Ground
body, as recommended in the guide:
if WALL_TILE_TYPES.contains(&tile.type_) {
let shape = ShapeHandle::new(Cuboid::new(Vector2::new(
Tile::SIZE / 2. - 0.01,
Tile::SIZE / 2. - 0.01,
)));
let translation = vector;
physics.build_collider(
ColliderDesc::new(shape).translation(translation),
physics.ground_handle,
false,
);
}
My game starts lagging when I have more than 50 blocks, which seems like a completely reasonable amount. Is there a better way to handle tilemap-based collisions? Are there any ways I can optimize this, aside from writing an algorithm that decreases the number of colliders in my world?