The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
HoloToolKit lock y-axis in HandDragger
I would like to use the HandDragger.cs script to move something in my project. But I'd like to set the Y-axis transform to either, (preferably) a variable or just a static height. Admittedly, I'm very new to coding and can't exactly find which variable sets the dragged y value.
Is this code more in depth than simply locking an axis within the update dragging?
I thought it was within:
"float distanceOffset = distanceRatio > 0 ? (distanceRatio - 1f) * DistanceScale : 0;"
and tried changing the middle variable here to just a 1f, but that didn't have the desired affect.
I had used these lines of code in a different script that would do something similar;
Vector3 newPosition = Vector3.Lerp(transform.position, targetPosition, DragSpeed);
transform.position = new Vector3(newPosition.x, transform.position.y, newPosition.z);
While this worked to lock the y-axis, the script was missing a lot of the functionality that the HandDragger script had already accounted for.
This is what I think is the relevant snippit from the HandDragger.cs script;
private void UpdateDragging()
currentInputSource.TryGetPosition(currentInputSourceId, out newHandPosition);
Vector3 pivotPosition = GetHandPivotPosition(); Vector3 newHandDirection = Vector3.Normalize(newHandPosition - pivotPosition); newHandDirection = mainCamera.transform.InverseTransformDirection(newHandDirection); // in camera space Vector3 targetDirection = Vector3.Normalize(gazeAngularOffset * newHandDirection); targetDirection = mainCamera.transform.TransformDirection(targetDirection); // back to world space float currenthandDistance = Vector3.Magnitude(newHandPosition - pivotPosition); float distanceRatio = currenthandDistance / handRefDistance; float distanceOffset = distanceRatio > 0 ? (distanceRatio - 1f) * DistanceScale : 0; float targetDistance = objRefDistance + distanceOffset; draggingPosition = pivotPosition + (targetDirection * targetDistance);
Thank you for your time