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.
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.
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?