I have this simple setup where I wish to test if I can trigger mouse hover effect on a Actor.
After reading posts regarding this topic I came to the following code. AUnitBase is a Pawn Class, I create a StaticMesh component and assign OnBeginCursorOver to trigger a function. Like so
Then In editor I have BP class based on AUnitBase and its in game area. I press Play in editor and then try to move mouse over this static mesh but nothing gets logged.
What else do I need to do to make this work ?
Hey @Ettu_R, welcome to the forum community!
I believe you have to enable clickable in your mesh component. I found another forum question that might help:
Thank you for reply @ZenLeviathan
I managed to get it working, sort of …
What I did was create a custom PlayerController for my PlayerPawn. Then in that controller I added
So now mouseover works. However, as I’ve read it will only work on StaticMesh ? I tried to add this to SkeletalMesh and that does not trigger mouseover ?
Is there any way I can make it work on SkeletalMesh ?
I have this dragon, which is animated and that I would like to have mouseover effect on. How can I make it so that mouseover works on that dragon ?
I made BluePrint from this C++ class and inside BluePrint, when I look at SkeletalMesh component, there seems to be possible to register mouse events. I added one like so
I think I figured it out! I changed collision preset on SkeletalMesh to “OverlapOnlyPawn”, which I believe now triggers mouseover from my PlayerPawn. Seems to work as I wanted
I have a situation I dont quite understand comparing C++ / BluePrint.
I have C++ baseclass and BluePrint made from that base.
When I try to make SkeletalMeshComponent to trigger hover effect through C++ it wont work, so the following code wont trigger
But if I got to blueprint, select SkeletalMeshComponent and manually set Collisionchannel to only overlap Pawn and add OnBeginCursorOver event through blueprint, it will work.
I had a lot of problems getting OnBeginCursorOver to fire in my Actor subclass in C++. I tried a lot of different approaches on various posts and nothing worked.
Commenting here because this post has had a lot of views and other posts I found expressed similar frustrations.
In the end this worked for me. Turn it on in the APlayerController subclass:
I did same as you @Ettu_R - with the SetCollisionResponseToChannel but my handlers were messed up (see below).
I also added the line above to set QueryOnly collisions enabled and also SetGenerateOverlapEvents to true.
I also moved the binding of the callbacks to after these flags were set up, just in case.
One thing to note is that the naming of the callback is arbitrary. I had gotten the impression that just naming it that OnBeginCursorOver would work, but of course it doesn’t. You have to bind handlers with these signatures: