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!
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.
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.
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.
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
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
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
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”
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
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… ?