#Continuously picking the mouse intersection with Ground mesh?

1 messages · Page 1 of 1 (latest)

small smelt
#

Hi, a begginer here having a tough time.
I would like to have a simple "ghost" mesh to be where my mouse is pointing at another mesh, labeled as ground.
I failed to do it using .observe() (only work when the "Over" state begins) and I failed to do it using the update system method from the bevy-picking example (I failed to recognise the ground among other meshes).

What is the most convenient way to just read the mouse intersection with a mesh in every frame?

quick iron
#

Well, picking (with observers) is the most convenient way. It seems you might have been using the wrong picking event for hover.

Heres the hover events and their docs descriptions:

  • Over Fires when a the pointer crosses into the bounds of the target entity.
  • Move Fires while a pointer is moving over the target entity.
  • Out Fires when a the pointer crosses out of the bounds of the target entity.

You want the Move event in your observer, that way you get events continously while the mouse is moving. Note: you only get this event when the mouse is actively moving, if its perfectly still you get nothing. One way to use it is to update some other entities transform with the coordinates from move.hit_data.position

#

You can use Over to spawn your "ghost" mesh, Move to change its position, and Out to despawn it

idle pendant
#

What is the most convenient way to just read the mouse intersection with a mesh in every frame?
If you want to do it every frame you can read Res<HoverMap>. It contains the realtime hovered entity and the world position of the hit.

quick iron
#

Yup, the events are generated from HoverMap