Is there a mouse hover event?

Is there a way to have it so where my mouse is hovering, to make an event/function fire.

For example, let’s say I have a cube in my scene, and I hover my mouse over the cube, and then the cube turns red or gets bigger or rotates etc.

1 Like

You have to use the mouse move event and on the event callback, check if there is anything under the cursor.

As a quick example, his a modified tutorial sample where the hot spots pulse when the mouse first enters:

1 Like

I see, is there a way to use AABB??

I think I have a solution based on your example though.

If you are referring to the bounding box on a mesh instance, then yes, you can as it’s the BoundingBox which has a intersectsRay function on it.

If it’s a 2D game in orthographic view, you can use screenToWorld on the camera to get a world space position and do a standard point in box check.

wait i think i got it

Yea I figured it out exactly how I want it! Thanks.

Basically going to build my home page of my game site using playcanvas and have 3d objects be the UI to select my games.

1 Like

the link is dead, can you please direct me to this project? thanks.

I think I’ve deleted it in a cull. Sorry.

could you guide me to an example of how to check if there is anything under the cursor on the mouse move event?

Just the API links above and the original project that I modified to do ‘mouse hover’

the link you had given its shows 404 error