3rd Person Check if player is looking at object

I’m looking to set up a function that determines whether the third person template character is looking at an interactable object.

So far, the way I’m doing things is by having a function determine whether the player is close enough to an interactable to interact with it. The way I’m imagining this working is there being a field of view directly in front of the player (like a cone in front of them that represents their vision) that can check whether the object is within that cone.

I’ve tried a couple different approaches, but all of them either always return false or only work if the object is out of view of the camera (the provided screenshot), the player’s field of vision. I will admit I’m not the most math-savvy developer, so if anyone has advice for how I could edit these to get the results I want, that would be a huge help. Thank you!

Hello,

There’s a lot of code missing, so I’m unsure of how you’re approaching this.

However, you can create a collision geometry (cube, capsule, cone) that checks for actors of a specified channel that protrudes from the camera/character. Make sure that you specify the overlap channel, otherwise this trigger geometry will interact with everything.

Apologies, here’s a bit more of the BP that I have.

As it works right now, the interactable checks on tick whether the player is near them or not. Essentially what I want to do after that is another check for whether the player is looking at the interactable (I.e. within that certain area of the 3rd person’s view that I want to establish).

My hope was to do this without using collision whatsoever as I’m trying to use this as an exercise to learn other parts of blueprints and UE5, but if there really isn’t another good way of doing this, I can probably give this a shot.

I see.

I would not use an event tick, personally, as for larger projects, it can become quite taxing.

Anyway, I’m unfamiliar with the correct usage of this function (at the moment) so I can’t point any errors out. Maybe someone else can.

I would monitor the rotation values with PRINT STRINGS, as you mention that this always comes out false.

It’s possible that your Mesh is not aligned with the Camera and/or its Capsule. As you are getting the ACTOR ROTATION and not necessarily the rotation of the Mesh.

Thank you for all the advice!

I’ve since found a much easier solution to achieve what I wanted; using a sphere trace and adjusting the radius to what I want the look at range to be. Probably not as clean as it could be with a cone shape, but this gets the job done pretty nicely!