Announcement

Collapse
No announcement yet.

How to know if player is looking at a object?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to know if player is looking at a object?

    Hello there!

    I'm making a slide door that open/close when the player push a keypad. I have done the feature of open/close when the player press left mouse when entry in the keypad's trigger, and I have setup a variable that indicate if the player can or not interact. The only thing left is do that the door only open and close if the player is looking directly at the keypad


    You can see in the photo that the red circle indicate the keypad zone that must be seeing by the player to be able to open it, and the blue, the trigger inside the player must be in.

    I have been trying do that with the trace line by channel, but it didn't work. Also tried with multi line trace by object, etc. Any of them didn't worked. I dont find the way to detect if the player is looking at the keypad.
    Last edited by Cerb19; 10-29-2017, 02:57 PM.

    #2
    Originally posted by NineTailedFox12 View Post
    I have been trying do that with the trace line by channel, but it didn't work. Also tried with multi line trace by object, etc. Any of them didn't worked. I dont find the way to detect if the player is looking at the keypad.
    Im pretty sure the traces work just fine if you got collision setup properly, either make the keypad a separate mesh/component or add a simple collider to it that you can trace.

    Comment


      #3
      Originally posted by Lambdarevolution View Post

      Im pretty sure the traces work just fine if you got collision setup properly, either make the keypad a separate mesh/component or add a simple collider to it that you can trace.
      Yes, it worked, but when I choosen the "world static" option on the line trace by object, it detect the entire actor, and I only want it to collide with the keypad's trigger (In my actor component I have the frame, the door and the keypad). Anyway, I'll play with the collisions until it work. Thanks!

      Comment


        #4
        Go into your project settings and search for "Trace Channels" create a new one called "Interactable", or whatever you want and set default to "Ignore", click accept. Add a box collision to the blueprint and position it where you like in front of the keypad. Change the Collision properties of the box collision to ignore everything, except set "Interactable" to block. Now do a line trace by channel and make sure "Trace Channel" is set to "Interactable". Should do the trick.

        Comment

        Working...
        X