How to detect On Mouse Over events

How can you determine if the mouse is over an Actor? The Script class doesn’t have an event for that

Just any actor or UI controls?

For any actor I recommend following this tutorial https://docs.flaxengine.com/manual/scripting/tutorials/decal-on-mouse-click.html and then from the hit of the raycast you could check for all kinds of things. If an actor is a specific type, if an actor has a tag, if the actor has a layer, etc. You may need some sort of collision for the raycast to hit certain actors.

From this, then, I gather that the engine doesn’t have OnMouseEnter/Over/Exit events. If I understand correctly, then it seems like I would have to poll what is under the mouse on each Update.

It has those events for UIControls like buttons, images, etc. But not for regular meshes in the world.

OK, thank you. I don’t see this on the road map, so I’m guessing it’s not a priority. So, polling each frame is the recommended approach?

I suppose it’s all relative when the goal is to capture thru illusion.
UICanvas under Model a couple weeks ago.
Flax_UI
Dev Log #10 - YouTube

Seems like for picking scene objects, you’d only test when you need it.
But an all the time on ‘what am I over’ would be a neat one ray per frame feature.

1 Like

Thank you. That’s a pretty slick UI. Did it take you long to make it?

A few hours to do the mesh.
A few hours to figure out how those positioning controls on UICanvas worked.
I was dipping my toe into the recent ArizonaFrameworkSample and banging my head against rocks trying out the C++ scripting. I crawled back to C#. :slight_smile:

2 Likes

LOL, I know what you mean :rofl:

2 Likes