Download

How can I trigger an event when aiming at something in an FPS?

I’m using the default FPS template and want a widget to appear when my crosshairs are over an object. I have been unable to get the Event Begin Cursor Over to work for this - I have to aim at weird angles for the event to trigger. I think this is because the actual cursor moves at a different rate than my camera and crosshairs. What are some ways I could solve this problem? Thanks in advance :slight_smile:

You can use a linetrace, from your camera in the direction of your camera ( where you’re looking) out into the world to find what the crosshair is over;

from there you can decide what to do, based on what the player is looking at

b5102ab09e0816cc877ba3eb86d4656bf00b94b4.png

Thanks for the reply! Which Blueprint would I add this in?

You could add it in your player character or controller.
The blueprint would need to have a reference to the widget that you want to update.
When your line trace hits an actor, you’d use the widget reference to control the attribute of the widget that determines what it displays/if it’s visible or not.
The widget would always exist, but go invisible whenever your line trace does not hit a valid target.

Your biggest hurdle would be to optimize it such that there isn’t much of a performance loss from doing this every tick.