This will be a long post, so bear with me.
(Also, I don’t know how experienced you are, so I will explain this like you’ve never done this before)
Here is what I did in my project:
This step is essential to make my approach work.
To make the communication between blueprints easier, I made a Blueprint Interface, you can find it in there:
http://i.imgur.com/wl56Rxi.png
the content of my BP Interface looks like this:
http://i.imgur.com/XZiOSlU.png
really simple and will do the job.
Now, here comes the more complicated part. In your case, this is for the ThirdPersonCharacter Blueprint.
http://i.imgur.com/QJtJz2L.png
This will draw a line from your characters head, to the mesh/actor you are looking at with your camera.
I’ll walk you through this, since you’ll probably need to modify it a little.
So first we get a reference to the Character Mesh, then we get its world location. Now we need to add a bit to this vectors Z axis value, since we need the location of the head. This is what the macro “MakeLineOfSightVec” does in my example (the name is a bit off, since I used it for something different before).
You will need to replace this macro with something like this:
http://i.imgur.com/XPmgl7b.png
So you break the vector of GetWorldLocation and add to the Z value.
Now, how much you need to add to Z depends on how tall your character is, you’ll probably need to play around with it. Then you make it a vector again and plug the result into the Start of LineTraceByChannel.
Next we need to figure out where the player is looking. For that, we get a reference of the Camera. (I named mine after the camera in the 3rd Person Template, so yours should also be called Follow Camera.) We plug the Reference into a GetForwardVector and multiply it by a float. This float determines the range, so how far the line will be drawn.
The result of this multiplication will be added to the result of your Make Vector. The sum needs to be plugged into the End of LineTraceByChannel.
The whole LineTraceByChannel gets executed by the EventTick Event.
A little note here. If LineTraceByChannel doesn’t get you the results you want, you could also use LineTraceForObjects. With that, you can look for specific types of objects.
http://i.imgur.com/hTZNKnG.png
Back to where we were. To know which actor we’re looking at, we need to Break Hit Result. Since we’re only looking for Actors we can interact with, we need to filter a little. So we plug the Hit Actor into Does Implement Interface, and select the Blueprint Interface we created in the beginning.
Now we can use this with a button. If you want to use the mouse click, you should create a new binding for that in your Project Settings.
This InputAction now goes into an If Branch, since we only want to be able to activate the actor if we’re looking at it.
Therefore, we plug the Return Value of “Does Implement Interface” and the Return Value of “LineTraceByChannel” into an AND, which will serve as the condition for our If Branch.
If the condition is True, we fire our Function Message. To create this node, just search for the name of the function that is inside the Blueprint Interface you created in the beginning.
AAAAnd that’s it for the Character Blueprint.
Now, we need to make the targeted actor actually do something when triggered.
To do this, we need to create a new Blueprint Actor.
Preferably, you right click the mesh you want as your actor in your Content Browser, and create a blueprint from this.
http://i.imgur.com/gyDcEyY.png
Now some necessary prep work.
Inside the Actor Blueprint, you go to Class Settings and add the Blueprint Interface you made.
http://i.imgur.com/rmok9EN.png
This will allow you, to use the Event we need.
If you right click → add event, you should be able to see an Event for the Blueprint Interface.
http://i.imgur.com/Euq47cJ.png
This event will be fired, when the If Branch in our Character Blueprint is True.
Now you can start your Matinee with this Event (or whatever you want the actor to do).
Phew, that was a long one, I hope this will help you out.