pulling back the slide with how far your hands are moving back, and being able to move the slide back by how close your hands get again. i currently have a VERY wonky way of calculating this with the magnitude and then checking if the unit.Z vector is positive so im not able to do this:
yeah about the code, im p sure its an entirely wrong way to calculate but here anyways
lastpos3232 is the startposition of the VR hand and this is all in a renderstep loop input value
local magnitude = math.abs((realrhand.Position - lastpos2312).Magnitude)
local unit = (realrhand.Position - lastpos2312).Unit
print(realrhand.Position.Z - lastpos2312.Z)
magnitude = math.clamp(magnitude*5, 0, 1)
--you can ignore this line reallhand.CFrame = lhand.WorldCFrame
if unit.Z> .1 then
object.M6D.C0 = object.M6D.locked.Value:Lerp(object.M6D.max.Value, magnitude)
end
the locked value is theslide when its not pulled and the max is the max itll pull back
its just very wonky for example if i move in the other direction in the direction of the slide it glitches out, and its very wonky in general
I think it has to work similarly to UI sliders, but also take rotation into consideration. Which is not that hard using CFrames.
I’d try saving the hand position when the player starts pulling the barrel back, and then check every frame how far the hand has moved from that spot. Make sure this start position is compared to the handle, so walking away doesn’t affect it. Then clamp the value so the barrel doesn’t move too far back, and use another part’s LookVector (or another directional vector) to get the axis on which the barrel has to move back.