How do you do the dual weld in VR for guns?

  1. What do you want to achieve? Keep it simple and clear!
    I want my gun welding in VR to be more clean. But there is a problem. I don’t know how. Think of it as you are playing a realistic VR FPS game where you can hold your gun with 2 hands. Go to the link below if you want to understand more.

Or have the gun welding system to be similar to OPPOSER VR.

  1. What is the issue? Include screenshots / videos if possible!
    This.

As you can see, when I try to hold it with 1 hand, it works fine. When I try to hold it with the other, the welding got wonky.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I did look here Link but it didn’t give me a clear answer. Both of us used AlignPosition and AlignOrientation.

THINGS TO NOTE:

  1. The white orbs are the REAL VR controllers.
  2. The AlignPosition and AlignOrientation are both in the fake hands. The attachment0 is the fake hand attachment and the attachment1 is the white orbs attachment
  3. I used Motor6D to weld items. The parent of the Motor6D is the fake hand, the part1 is the offhand part (left hand welding part) and the center part (right hand welding part)
  4. AlignPosition’s maxforce is 2000, maxvelocity is infinite and responsiveness is 200. Alignorientation’s maxtorque is 1000, maxvelocity is infinite and responsiveness is 200.
  5. This game is SINGLEPLAYER FOCUSED. Meaning I don’t care what happens in the server.

The code below is what happens when I grab the part. the ActualHand is the hand that is grabbing.

elseif Parttograb.Name == "OffhandPart" and Parttograb:FindFirstChild("C1CFrame") then
	ActualHand.Welder.Part1 = Parttograb
	ActualHand.Welder.C1 = Parttograb.C1CFrame.Value
end

WHAT I TRIED:

So in conclusion. I tried quite a few things to get the 2 hand gun welding system working but most are just too wonky. How does OPPOSER VR do this thing?

accidentally posted my last post while making it :skull:

Hey! As the VR developer for ATHENA, I can 100% help you out, though I may be a bit late.

You’ll want to be using Quaternions to make it feel very smooth.

Don’t understand quaternions? Don’t worry, neither did I. I actually used a quaternion cframe module for this. I’d recommend using this one (LuaQuaternion)

first, set a weight variable:

local alpha = 0.5 -- 0-1

you need to now get your right and left hands as cframes (I used “right” and “left” in this example)

next, you’ll need to turn your hand cframes into a singe quaternion using lookAt:

local look = quaternion.lookAt(right.position,left.position,right.UpVector)

now, use that weight variable with Slerp:

local qa = quaternion.fromCFrame(right) -- used as base value for slerp
local newQuat = qa:Slerp(look,alpha) -- alpha is our weight variable
local finalCFrame = newQuat:ToCFrame(right.Position)

now set your gun’s handle CFrame to “finalCFrame”, or the worldCFrame of the attachment

repeat this for the left hand by swapping “right” and “left”

You should get a result similar to my own: