-
I'm using this version of bevy [dependencies]
bevy = { version = "0.16.1", features = ["dynamic_linking"] } And the automatic instancing example doesn't run the update function for some reason. Maybe things have changed in the new version of bevy? fn setup(
mut commands: Commands,
assets: Res<AssetServer>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<CustomMaterial>>,
) {
let image = assets.load("branding/icon.png");
let mesh_handle = meshes.add(Cuboid::from_size(Vec3::splat(0.01)));
let material_handle = materials.add(CustomMaterial {
image: image.clone(),
});
let image_dims = UVec2::new(256, 256);
let total_pixels = image_dims.x * image_dims.y;
for index in 0..total_pixels {
let x = index % image_dims.x;
let y = index / image_dims.x;
let world_x = (x as f32 - image_dims.x as f32 / 2.0) / 50.0;
let world_y = -((y as f32 - image_dims.y as f32 / 2.0) / 50.0);
commands.spawn((
Mesh3d(mesh_handle.clone()),
MeshMaterial3d(material_handle.clone()),
MeshTag(index),
Transform::from_xyz(world_x, world_y, 0.0),
));
}
}
// Animate the transform
fn update(time: Res<Time>, mut transforms: Query<(&mut Transform, &MeshTag)>) {
for (mut transform, index) in transforms.iter_mut() {
// Animate the z position based on time using the index to create a spiral
transform.translation.z = ops::sin(time.elapsed_secs() + index.0 as f32 * 0.01);
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
dr-nyt
Jun 16, 2025
Replies: 1 comment
-
Ok, I was stupid, I had added it as a Startup system... |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dr-nyt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, I was stupid, I had added it as a Startup system...