#Sprite picking doesn't trigger with multiple cameras

2 messages · Page 1 of 1 (latest)

wind delta
#

Hello, I'm working on a pixel game with a very similar setup to the pixel_grid_snap example, but I can't get On<Pointer<Click>> to activate. I even tried modifying the pixel_grid_snap example directly on the latest Bevy in main (ed86a8917) and nothing seems to happen.

Code (using the pixel_grid_snap example):

I added this function to respond to the click event:

fn on_click_sprite(_click: On<Pointer<Click>>)
{
    info!("clicked sprite");
}

Then I modified how the sprites were spawned like this:

commands.spawn((
        Sprite::from_image(asset_server.load("pixel/bevy_pixel_dark.png")),
        Transform::from_xyz(-45., 20., 2.),
        Rotate,
        PIXEL_PERFECT_LAYERS,
    )).observe(on_click_sprite);

commands.spawn((
        Sprite::from_image(asset_server.load("pixel/bevy_pixel_light.png")),
        Transform::from_xyz(-45., -20., 2.),
        Rotate,
        HIGH_RES_LAYERS,
    )).observe(on_click_sprite);

When I click the sprites, I would expect to see the info! message print to the terminal, but nothing happens. Is there a setup step I'm missing here?

hushed valley