Download

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]

872058052e11db48dfa114f7bd31817e687751a2.png
[HR][/HR]
70e7c8b99a1e942be30ed3a96e2c1d4cc84fe43a.png
[HR][/HR]
de2d5f96266547c608660b18991f8d60bb6d3955.png
[HR][/HR]
a5eee1e672dc875d157d3b15a444ba5d6fcc1daa.png
[HR][/HR]
9ae3634201093fff14123027137a6e11432cfbf7.png
[HR][/HR]


[HR][/HR]

[HR][/HR]

Slight correction:

0699ae68421af30e26bc62a590335d38abdcdcdd.png

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