Enable action only when I look at an object

How can I do this action only when I look at the object?

Thanks !

Here is a link of how it is done in C++:

Look especially at the “*Character.cpp” section of the GetUsableInView() function, as that can easily be translated into BP

And an implementation of it here in BP:

Finally, It is a simple matter of getting the Camera position and rotation. Casting a ray from that to the first item hit. After that, in the HitResult, cast the returned actor to the object that fires off an event when it is looked at, then call the event function.

I’m not sure exactly how to do this, but I saw in another person’s tutorial they used something called “Get Actor Forward Vector”, which let you do some branching depending on the position of the camera view and the other actor:

Ok, i followed the instructions and it works, but I can not do trigger the event matinee instead of destroy actor

Hi,

Are you calling the destroy actor before you call the matinee? If so you need to do them the other way around, destroy completely stops any functionality after it has been called and should (generally) be placed at the end of a function.

No, I want to replace the “destroy actor” with an event matinee, can i do ?

I would recommend a timeline, but yes you can. If when you look at it you run a “cast to” the object you should be able to access the timeline (which I would set up in the actor in question instead of in your player script).

basically I need to activate an animation in matinee of an object only when I look at it and press a button.
sorry for my english but it is not my mother language :slight_smile:

Your English is very good! You should be able to do a matinee in much the same way. Once the trace hits you can still cast to the object to access the matinee.

Hi ,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.
Thank you.