#Selecting entities in a 3D grid with mouse

3 messages · Page 1 of 1 (latest)

ocean panther
#

Hoping this question and explanation makes sense: I have a bunch of entities with a Position component, where every unit of Position translates to 0.25 units in regular coordinates, so the end result is that the world is divided into a set of 3D cubes that are 0.25 units wide.

I want to select an entity located at an arbitrary Position with the mouse, which presumably means casting a ray until it intersects with a cube containing a selectable entity. What's the right way to do this? I know there's Camera::viewport_to_world(), but all the explanations about intersections with planes and I don't know how to adjust that to this system in a way that isn't jank.

(Also unsure how to select entities that are behind other entities, but that might be a design problem... if anyone has advice on that, it would be appreciated too. ^^" )

green meadow
#

I've been using the bevy_mod_picking crate, it's well documented and the dev is in this server and will reply in the #1034543904478998539 thread for it

ocean panther
#

oh, dang, I completely forgot about bevy_mod_picking