Oculus VR, get controller motion to move player, using Blueprint

I want to use the controller position to move the VRPawn. How can I do this? I can get the controller position fine, but how to move the VRpawn? Simple solution needed, thanks

How exactly do you plan to link the position of the controllers to the magnitude / direction of the movement? Offset from the center of the pawn or HMD? Frame by frame displacement? Something else?

…Im not sure, i just want to get anything working and build on that - controller Y for example could give an impulse to the pawn

You can use Get Relative Transform on your motion controller components, then break the transform to extract their relative position. Project the relative position on the XY plane and use the projected vector to drive the pawn movement.

This said, if you only have very limited experience with blueprints, it won’t be easy for you until you have gained more expertise.

ok thanks!!, in the end because I wanted to see some numbers, I made a HUD and put a Motion Controller inside it. Then I get the ‘World Transform’ and ‘Transform Location’ it then ‘Break Vector’ to get ‘Y’ then ‘Draw Text’ it onto the HUD.

  • But how to get this ‘Y’ value into another Blueprint?? There seems to no coherent explanation about Cast To - in the docs it says “When using a Cast To node in Blueprints, put simply, you are attempting to check if the object you are casting from is the specific object you casted to.” - clear as mud!!

It is difficult to help further without seeing any of your Blueprints. In principle any code that moves your Pawn should be in the Event Graph of the Pawn itself. You can use Event Tick to get the displacement of the motion controllers on a frame by frame basis, then apply the movement to your Pawn either with Add Actor World Offset (useful if your Pawn doesn’t have a movement component) or Add Movement Input (if your Pawn has a movement component).

Regarding Cast To, you have to think of it as an attempt to transform the class of an object from A, typically a more generic parent class, to B, typically a more specialized child class of A. If the transformation is successful, you can treat the original object as an object of class B and therefore use all its specialized functions (methods) and variables (properties). This concept belongs to Object Oriented Programming and it is used in UE4 Blueprints because of the underlying C++ code and the fact that many object classes are derived from other classes. Here is a UE4 specific example which can be useful to understand.

Actor is the generic parent class all Pawns are derived from. Pawn is a child class of Actor. Pawn is more specialized class and has more functionalities than Actor. MotionControllerPawn is a even more specialized class derived from Pawn so you can fully customized its behavior. In other words Actor → Pawn → MotionControllerPawn.

Now, to make UE4 nodes as generic as possible, they often return a reference to the less specialized class Actor, otherwise you would need a different node for any possible child class of Actor. One example is when you perform a Hit Test and receive back a Hit Actor as a result. Hit Actor is of type Actor, which is the generic class.

In principle you don’t know if the Hit Actor is your MotionControllerPawn until you try to transform it (Cast To) your MotionControllerPawn. If the transformation is successful, you know the Hit Actor is actually a MotionControllerPawn and, as a consequence, you can start using its specialized methods (functions) and properties (variables). You could also Cast To Pawn, but then you will only be able to use the Pawn’s more limited functionalities.

If the Cast To fails, you know the Hit Actor is not a MotionControllerPawn and is probably something else. Within UE4, a Cast To is often used in this way, to check whether a generic reference returned by a node is actually pointing to a more specialized blueprint class.

Hope this helps, I know it is not an easy concept to grasp.

Thank you for this clear explanation vr_marko! :slight_smile: