Using Controllers to Scale/Rotate/Re-position World

What I’m trying to do is essentially emulate something like what you get in the VR Editor mode, where if (on the Vive) you squeeze the grip buttons on both the controllers, you can use that to scale and move the world around you.

Starting from something similar to the 4.13 VR template, my intention is to use player input to change the transform on VROrigin and basically have the player make themself bigger or smaller, and otherwise transform when they grip both controllers and move them. In such a way that from your perspective it looks like the controllers remain static in the world, but the world moves around you with them when you move the controllers.

As such, mostly just wondering if that’s a control system anyone has already tackled or found a straightforward way of doing. Otherwise, I’ll put the blueprint up here for other people’s reference once I figure it out :slight_smile:

Okay, mostly got it figured out. The following mostly works just fine, so I figure I’ll document it to save anyone else doing the same thing time.

This is just extending the default pawn with motion controllers in the 4.13 VR starter set, which has a Root component, a VROrigin scene component under that, and then the camera and the two controllers get attached under VROrigin.

Essentially what it’s doing is storing the positions of the controllers on the previous tick, then getting the current positions of the controllers, working out a delta transform from the old positions to the new ones and applying that transform to the VROrigin. Some of the math is a bit hacked together because you can’t just write matrices in blueprint and I don’t know how to make Transforms particularly elegantly.

The trickiest thing has been figuring out scale. I initially figured I could just transform the VROrigin directly, but while that works for translation and rotation, things get screwy for the headset controller and its IPD when rescaling. So in the end I’m translating and rotating the VROrigin, but the scale is applied through Set World to Meters Scale only.

That introduces the problem of how you calculate the delta between the old and new positions of the controllers, given that they are moving themselves along with the rest of you through the world. I figured I’d avoid it being self-referential by only getting the controller positions to store as the ‘old’ positions after applying the transform, so at the start of the next tick the old and new positions are in the same space, but Set World to Meters Scale only seems to kick in at the next tick, so when you store the controller positions after that, they’ve been rotated and translate, but not scaled. So you need to store the scale factor and apply it manually to the stored positions, so that they’re in the same space as the new positions on the next tick.

Hope that all makes sense!

[HR][/HR]


[HR][/HR]

[HR][/HR]

[HR][/HR]

[HR][/HR]

[HR][/HR]

[HR][/HR]

[HR][/HR]

Slight correction:

You want to apply the translation separately. This error wasn’t really noticeable in the really small deltas when creating a transform from frame to frame, but was causing big offsets when using the point-to-point transform in more general cases (it’s a decent enough way to line up a scan of a real space with the actual space).

Hi!

Hello!I read it and followed you to do it.But it cannt work.Could you please share your source to me?Thanks!

Thanks

Oh,i am sorry,my email is 425532859@qq.com

This looks great, but I am unable to get it to work. Can you show the blueprint for the “Construct Transform” function? It is used twice within the “Construct Delta Transform” function. Thanks!

Interresting stuff… Would love to see it in action.

Yeah video will be cool to see where did you reached with all above BP .

Sorry to necro this thread, but its literally the only one I’ve found that talks about this type of interaction. I think as @Holoplex had mentioned, the BP for the “Construct Transform” function seems to be missing. I’ve ventured to guess what it would contain, but I don’t think I’m getting anywhere close to the mark.

Sorry to again “Re-Necro” this thread. Is this a valid solution to try to implement? I don’t need to scale or rotate. I just need to be able to move myself or the level up, down, left or right by using the grip buttons and moving the controller up, down, left, or right.

Hi, is here more info of how o do this, thanks

Necro: I’m building similar functionality, I have Grip/Grab movement and rotation working well but scale is giving me all sorts of problems.

Has anyone been able to solve this in a way they’re willing to share? Here or via email etc…

When I finish this push I’ll try to circle back and make a post to share my implementation of grab movement/rotation (and scale if I can get it to work) with the broader community, it’s took me way to long to get to this point and I have so much more to do, but other people’s shared efforts definitely helped along the way.

video that shows the scale jitter (and other stuff): Grip Move/Rotate/Scale.. testing - YouTube

Hi, I’m back. made a VR/GripDragRotate implementation that I wanted to share with the community. I went ahead and stripped it out of my project and included a little readme with steps to add it. I’ll add the git repo here. If anyone wants to check it out and use it, feel free. If you’re able to make any improvements or know how I can get the scaling to work please let me know. I tested to make sure it works using 4.27.2 and my Quests (1/2) , works with the current VR Template as a base. GitHub - KavanBahrami/UE_VR_Locomotion_GripToMoveRotateScale: Unreal Engine Virtual Reality Grip/Grab Locomotion. Grab to Move / Rotate (Scale not quite working)

3 Likes

Hey, back again, I finally got scale working! Put that part of the project down, then came back to it today with fresh eyes and here we are, 5 hours later and it works. I’ve updated the previously linked github repo with the updated code. So if anyone finds this in the future, that’s the place to look for the example implementation.

Happy coding and best on your projects!

2 Likes