#Sprite Picking fails when a Transform has a Scale with a Z value = 0.0

1 messages · Page 1 of 1 (latest)

dull ruin
#

I ran into an issue where Sprite Picking fails when a Transform::from_xyz(x, y, z).with_scale(Vec2::splat(2.).extend(0.)) is included in the Bundle

System Details:
Bevy 0.16.1
Rust 1.86.0
OS: NixOS 25.05

I'm rather new to Bevy, especially regarding Picking, so lmk if I'm missing something obvious here.

#

Testing code and the asset that I'm using

haughty loom
#

i dont know how much that would influence, but try a non-zero Z for scale

dull ruin
#

@haughty loom Weirdly enough, that actually makes it work ...

#

But I feel like it shouldn't affect it

dull ruin
#

Okay, I think it's something in the transforms in how the alpha value is determined

#

With some good old println debugging I found that with Transform::from_xyz(x,y,z).with_scale(Vec2::splat(2.0).extend(0.) the alpha value is 0.0 and with <snip>.extend(0.1) the alpha value is 1.0 and the click event works

#

But before I go any further on this, the question should be "is this intended behavior". I'm not up to speed enough on the math behind transforms to know if this is intended, or if this matches with what we would expect from sprite picking

#

Sprite Picking fails when a Transform has a Scale with a Z value = 0.0

summer prairie
#

that's not too surprising, a scale of zero on any axis is going to give that thing zero volume

#

is there some reason you aren't extending with a scale of 1?

dull ruin
#

Just a habit a carried over from 2D translations, I guess

haughty loom
#

but it will take some time

dull ruin
#

Is there ever a use case for a scale of 0? Is this something worthy of a bugfix or a lint, or am I just unintentionally attempting to do something that doesn’t make sense?

#

Tbf I haven’t check if there’s already a lint in the bevy linter for this. Haven’t gotten that set up in my main project yet