Download

How to find out what the player camera is directly looking at?

I’ve just downloaded UE4 and have been messing around with the blueprint system, and I have been unable to find a way to find out what object is directly in front of the camera? (For things such as interacting with switches and such)
I am aware that there are volumes and such which I could use for a similar effect, but I would like to use something similar to ‘raycasts’ from the Unity engine, in which it sends out a ‘line’ from a vector, in a direction to another vector, and returns the first object it hit’s if any. :slight_smile:
I have tried to use the ‘Single Line Trace for Objects’ but I am unable to either: get the position of the player camera, or I am unable to use "Line Traces’ as a method for this? I am unsure as to which is wrong :confused:
Any help would be appreciated :slight_smile:

I think the camera forward vector = controller forward vector, you can see an example of it in the character blueprint in third person game project

so then you can rotate your trace start position by it

please know I’m not fully sure.

Thankyou for answering, but no, I believe that the ‘Control Rotation’ refers to the capsule that makes up the whole collision model :slight_smile:

No problem, for me i used it to get the cross product with pawn forward vector and it works

This should be the correct solution :slight_smile:

2 Likes

Thankyou :slight_smile:

Ok, here is my set up for the input, but it’s not working? It almost seems like the input isn’t firing? -

Imgur