Announcement

Collapse
No announcement yet.

Opening a door when the player's cursor is over the object, as well as being inside a collision box

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

    Opening a door when the player's cursor is over the object, as well as being inside a collision box

    I'm trying to figure out how to create a door that can only be opened when the user is looking at the door as well as them being inside the collision box. As of now, the user can open the door whenever they are inside the collision, regardless if they are looking at the object or not, which isn't what I want.

    Click image for larger version

Name:	38fe1446226ee44bd1c005a752f6d38e.png
Views:	1
Size:	174.2 KB
ID:	1179414

    I've tried searching for other examples of people wanting to do this, but I couldn't find a thing. I know that the overlap section is incorrect and needs to be paired with the begin cursor section for it to work, but when I try to pair them together, the door refuses to open. Any ideas on how to fix this?

    Click image for larger version

Name:	93830084baa2ca9941a8311b7cab9afe.png
Views:	1
Size:	156.5 KB
ID:	1179415

    #2
    Boolean algebra has some use here.

    for you best node would be "binary AND"

    Comment


      #3
      Originally posted by Nawrot View Post
      Boolean algebra has some use here.

      for you best node would be "binary AND"
      I don't see where that is in the list

      Comment


        #4
        Drag from any boolean RED pin, and type "AND"
        You wil lget and node.

        Connect states where trigger is in view AND player is inside overlapping trigger.
        Result of that AND will be true only when you inside and see switch.

        Comment


          #5
          Originally posted by Nawrot View Post
          Drag from any boolean RED pin, and type "AND"
          You wil lget and node.

          Connect states where trigger is in view AND player is inside overlapping trigger.
          Result of that AND will be true only when you inside and see switch.
          This is what I've currently come up with, but I've done something wrong somewhere as the door still won't open. I've only been using Unreal for a few weeks and it's self taught, so I'm sorry if I'm missing something here which seems rather simple haha

          Click image for larger version

Name:	e9c82428acdef79a16895b31e11bbe2b.png
Views:	1
Size:	150.1 KB
ID:	1103569

          Comment


            #6
            I've just done this instead as it seems like the correct way to handle this, but again, it still won't work.

            Click image for larger version

Name:	90577b141c46ff265e6616be0b85e839.png
Views:	1
Size:	141.2 KB
ID:	1103570

            Comment


              #7
              Getting closer. Placed an event tick onto the branch handling the input, but from there, regardless if the player is looking at the object or not, the door will open if the player is inside the collision box

              Comment


                #8
                To check if the object is inside your player's vision cone (frustum) you must make the dot product between the Direction vector and the Distance vector between the two actors. May sound a bit complicated, but once you read here you can search for a more detailed explanation about the dot product.

                Comment


                  #9
                  Originally posted by Gbr View Post
                  To check if the object is inside your player's vision cone (frustum) you must make the dot product between the Direction vector and the Distance vector between the two actors. May sound a bit complicated, but once you read here you can search for a more detailed explanation about the dot product.
                  Wouldn't that allow the door to be open even if the door is only a fragment in the player's frame?

                  Comment


                    #10
                    Originally posted by iBenParry View Post
                    Wouldn't that allow the door to be open even if the door is only a fragment in the player's frame?
                    it depends on the acceptable value(degrees) you choose to start the door opening subroutine. When I made myself, I remember the dot product result of 50 degrees was a fine value, caught the actors even if it's in a fragment of my screen.
                    In your case you can set a lower value, try testing what is fine for you.

                    Comment


                      #11
                      You can add two Scene components, one on each door edges and check if the two are inside your cone vision, making separate dot products calculations

                      Comment


                        #12
                        Originally posted by Gbr View Post
                        it depends on the acceptable value(degrees) you choose to start the door opening subroutine. When I made myself, I remember the dot product result of 50 degrees was a fine value, caught the actors even if it's in a fragment of my screen.
                        In your case you can set a lower value, try testing what is fine for you.
                        Originally posted by Gbr View Post
                        You can add two Scene components, one on each door edges and check if the two are inside your cone vision, making separate dot products calculations

                        Would OnBeginCursorOver not work for this?

                        Comment


                          #13
                          Originally posted by iBenParry View Post
                          Would OnBeginCursorOver not work for this?
                          Yep, I just suggested another solution if you want to make it more accurate (will only trigger if the two door's edges are inside your vision cone). Sorry if that made you confused.

                          Besides that, how is your actual progress on making it trigger when it's inside your CollisionBox? Is it working correctly? If not, try posting your code here to see if I can help you. All that solution you are looking for should be easy to make.

                          Comment


                            #14
                            Originally posted by Gbr View Post
                            Yep, I just suggested another solution if you want to make it more accurate (will only trigger if the two door's edges are inside your vision cone). Sorry if that made you confused.

                            Besides that, how is your actual progress on making it trigger when it's inside your CollisionBox? Is it working correctly? If not, try posting your code here to see if I can help you. All that solution you are looking for should be easy to make.
                            Click image for larger version

Name:	2a2f5517d316ccc1b739ec308b6f9f62.png
Views:	1
Size:	172.0 KB
ID:	1103583

                            This is how it currently looks right now. As of right now, the doors are extremely buggy. Sometimes when you look at a locker door, the one next to it opens, or sometimes the one you're looking at opens, or nothing opens. No idea why this is happening as it seems to be hit and miss.

                            Comment


                              #15
                              Well, looking at this part of the code I can't figure out why you are facing this issue. This BP you post is your Character's BP?

                              Comment

                              Working...
                              X