Announcement

Collapse
No announcement yet.

How to get world position of the hands controllers?

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

    How to get world position of the hands controllers?

    Hi there!

    I'm currently working on my master degree. I won't enter in the boring details, but I'm kind of a beginner with Unreal and I'm having a big problem. I really have to find a way to get the position of the controller. I've been passing over one month on this problem, I've been searching everywhere online and I tried a lot of stuff by myself but I can't figure out what to do.

    Is there anyone here who could give me an easy way to get a vector position of the hands controller of a vive with unreal in the VR template? You would save my life!

    #2
    The get the world position of the controllers, you can simply use GetWorldLocation with Target the Motion Controller component part of your VR Pawn (or dynamically spawn). There is not much more to it than this.

    There are other ways to achieve the same, i.e. calling platform specific functions (like on SteamVR: http://api.unrealengine.com/INT/Blue...ion/index.html) but it shouldn't really be needed in your case.

    This reference from the official documentation may be helpful to you: https://docs.unrealengine.com/en-us/...uchControllers
    CTO | Head of VR Development - Visit us at http://humanxr.com
    My UE4 Tutorials (mostly VR): https://goo.gl/GUvDyV

    Comment


      #3
      Thanks for the answer!

      Actually, I already saw those pages. For the first one, I can't find the node Get Hand Position and Orientation in the Blue Print Editore and, for the second one, it is a bit too advanced for me and It is to make a VR setup from scratch.

      The closest I found in the BluePrint Editor is this node : http://api.unrealengine.com/INT/Blue...en-/index.html

      Comment


        #4
        This is pretty basic stuff, if you want to do it within the MotionControllerPawn you simply do this:



        There are two variables in the MotionControllerPawn called "Left Controller" and "Right Controller", when the controllers are spawned these variables get filled with references to the motion controllers. You can then use these references to do all kinds of things. In the image I'm getting the world location of the motion controller's scene node and the actual mesh of the hand. But you can also get the location of any of the other components of the motion controllers.

        Now if you want to get this information from outside the MotionControllerPawn then you simply need to cast to it like so:



        Here it's nearly the same as the first image but I first get the player pawn then cast to to the MotionControllerPawn and from there we can get Left Controller and so on.

        Comment


          #5
          This function returns relaive position (not in world space). It's also SteamVR-specific and doesn't work for Oculus.

          You should use GetWorldLocation as vr_marco said.

          LeftController or RightController (in the MotionControllerPawn blueprint, reference to MotionController_BP blueprint) -> reference to MotionController component -> Get World Location
          Marketplace: Vive Mocap Kit / Fingers Solver / VR IK Body Solver / Subtitles to LipSync / Dialogue System with Character Animation
          And random stuff at Youtube

          Comment


            #6
            Thanks for your help, but as I said, I'm really a beginner in the blue print and it is kind of hard to understand what you mean. I'm sincerly sorry to ask it but could you simplify just a little bit for me? :-S

            Comment


              #7
              You should read and least Starter and VR sections in the documentation.

              Marketplace: Vive Mocap Kit / Fingers Solver / VR IK Body Solver / Subtitles to LipSync / Dialogue System with Character Animation
              And random stuff at Youtube

              Comment


                #8
                I tried, but every times, they talk about nodes I don't seem to have. Even thoe you show in the image, I can't find the "Right Controller", the "Left Controller" or even "Motion Controller" Node. I must do something wrong, but I can't figure out what! o.O

                Comment


                  #9
                  Originally posted by bdec View Post
                  I tried, but every times, they talk about nodes I don't seem to have. Even thoe you show in the image, I can't find the "Right Controller", the "Left Controller" or even "Motion Controller" Node. I must do something wrong, but I can't figure out what! o.O
                  There are members of MotionControllerPawn blueprint, so they're only available inside of it.
                  Marketplace: Vive Mocap Kit / Fingers Solver / VR IK Body Solver / Subtitles to LipSync / Dialogue System with Character Animation
                  And random stuff at Youtube

                  Comment


                    #10
                    Originally posted by Thor_DDI View Post
                    This is pretty basic stuff, if you want to do it within the MotionControllerPawn you simply do this:



                    There are two variables in the MotionControllerPawn called "Left Controller" and "Right Controller", when the controllers are spawned these variables get filled with references to the motion controllers. You can then use these references to do all kinds of things. In the image I'm getting the world location of the motion controller's scene node and the actual mesh of the hand. But you can also get the location of any of the other components of the motion controllers.

                    Now if you want to get this information from outside the MotionControllerPawn then you simply need to cast to it like so:



                    Here it's nearly the same as the first image but I first get the player pawn then cast to to the MotionControllerPawn and from there we can get Left Controller and so on.
                    Thanks for the update! I tried to follow your example, but when connecting the Cast To Motion Controller Component to the "Left Controller" node, I can't connect those two. I get the following
                    error message :


                    "Motion controller object reference is not compatible with motion controller pawn object rerference"

                    Originally posted by YuriNK View Post

                    There are members of MotionControllerPawn blueprint, so they're only available inside of it.
                    Thanks, I'll also investigate in this direction!

                    Comment


                      #11
                      Make sure you are casting to "MotionControllerPawn", you said that you were using the unreal VR template so it should work. You put down the cast to MotionControllerPawn then drag off the "as Motion ControllerPawn" pin and type in "Get Left Controller" and you get the node

                      Comment


                        #12
                        It works! Thanks guies! I really appreciate all your help! You saved my life! XD

                        Comment


                          #13
                          Hi. thanks all who've contributed to this thread.
                          I'm trying to do something simple, which is set the player motion controller as a variable in another blueprint (on event BeginPlay), because I don't want to create the same nodes over and over to get the position of the player hand. I have the variable type set as 'motion controller component'.

                          However, when I try this I get an error that property of Right Controller is None (I've set right controller as default in the BP_MotionController BP).

                          When doing the same thing on event tic, I can get the position of the hand just fine (using the same nodes).

                          It seems as though on begin play, the controller doesn't exist yet. Could that be the case? Or maybe I'm doing something wrong elsewhere.. ?

                          Thanks for your time
                          Attached Files

                          Comment

                          Working...
                          X