Download

Help: Blueprint First Person - Detecting when the player's reticle is over an actor

Hi everyone,

I’ve been working on the first person blueprint and have run into a problem that I’m sure is easy to solve… I just can’t figure it out.

I’m trying to get events on an actor to fire off when the player is looking at it. It works… ish. It does not seem to update it when it looks at the entire object, but instead just random parts of the object. I’m unsure if the object I’m using is the wrong type, or if I’m using the wrong function.

I’ve modified the player pawn to not have the gun, and added a PlayerController that has all the options for mouse interface checked except for show mouse cursor.

Here is the blue print I have on my simple object:

Any help would be appreciated, I have a feeling I’m missing something very basic for this.

I put this together for fun, seems to work pretty well.

Basically what you’re wanting to do it cast a collision trace from the start of your view, out some distance along your aim rotation. Then see what it hits.

Left side gets the players location with eye height included, then gets the end of trace by creating a direction vector from his rotation and adds it to the actor location.

Make sure to set the Object Types array for whatever you’re looking to detect hitting.

Works perfectly, easy to follow and effective. Also, good call on the Debug type for the line trace. I hadn’t played with those enough yet and really helps visualize what is happening.

As a side note. I did end up changing the Z in the rotate vector from the pawn as it was dipping far below my crosshairs.
[Edit]: this does not work, see below for fixed solution

Sorry for the long delay, I agree with 8-Line, this was a fantastic example, thank you!

My next step is to figure out how to tell an object that it is being looked at by the player, but I will spend some time figuring that out before I come crawling back asking/begging for help.

I’d recommend the following:

  1. Set up an interface in which your item (and all cognizant items) will use. You can also reuse an existing interface.
  2. On this interface make a function and set whatever inputs/outputs you need.
  3. In the specific item blueprint assign that interface (in the blueprint properties)
  4. Set whatever logic you want on the blueprint itself
  5. Once your player’s vector hits it then you can call on that function and use that object as the target.

I do something similar and have it working well. Will try to attach screenshots soon

Would you mind posting a screenshot? I am experiencing something similar with a mechanic of mine, and I cant quite seem to fix it.

You can actually take the same logic that was applied before. Just add to the rotated vector after the base eye height it added. Initially I added a static Z value, but realized it would mess up in the higher and lower angles.

Hello,

I’m an absolute beginner at this so I can’t make sense of all the stuff in the blueprint.
If I use construct a similar blueprint the crosshair “hits” the traget when it is above it.
Could you please tell me what did you use for Handle Distance and why and where did you get the Base Eye Height from?
Also, could you please post an entire screenshot of the bluprint?

Thank you.