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.
World Anchors supposed to remember rotation?
I'm having an issue with World Anchors and rotation in Unity. I am able to save/restore the position in the world just fine. And I am wrapping the rotation function with destroy/save (same as with translation). However, when the app re-loads, although my objects are positioned correctly, they still have the same initial rotation. Isn't it supposed to remember rotation?
Best Answer
-
Patrick mod
Rotations seem to be preserved in my simple application.
Considerations:
1. anchorStore.Save returns a bool-false means that it wasn't able to save.
2. when you add the WorldAnchor component it might not be immediately located.
3. I've found that if I don't delete the old anchor from the anchor store before saving a new one, it doesn't save the new one.Here's what I'm doing:
private void GestureRec_TappedEvent(InteractionSourceKind source, int tapCount, Ray headRay) { WorldAnchor anchor = gameObject.GetComponent<WorldAnchor>(); if (anchor != null) { anchorStore.Delete(AnchorName); DestroyImmediate(anchor); } transform.position = Camera.main.transform.position + Camera.main.transform.forward * 2.0f; transform.rotation = Quaternion.FromToRotation(Vector3.forward, Camera.main.transform.forward); { anchor = gameObject.AddComponent<WorldAnchor>(); } if (anchor.isLocated) { anchorStore.Save(AnchorName, anchor); } else { anchor.OnTrackingChanged += Anchor_OnTrackingChanged; } } private void Anchor_OnTrackingChanged(WorldAnchor self, bool located) { if (located) { self.OnTrackingChanged -= Anchor_OnTrackingChanged; anchorStore.Save(AnchorName, self); } }
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.(Daddy, what does 'now formatting drive C:' mean?)
5
Answers
yes they should. let me see if this still works for me.
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.
(Daddy, what does 'now formatting drive C:' mean?)
Rotations seem to be preserved in my simple application.
Considerations:
1. anchorStore.Save returns a bool-false means that it wasn't able to save.
2. when you add the WorldAnchor component it might not be immediately located.
3. I've found that if I don't delete the old anchor from the anchor store before saving a new one, it doesn't save the new one.
Here's what I'm doing:
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.
(Daddy, what does 'now formatting drive C:' mean?)
Thanks but you seem to have dropped some code between the transform.rotation line and the next curly brace?
I was destroying, was not deleting, trying again....
It's scoped funny because of cut and paste. There was an if condition that I deleted for the quick test.
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.
(Daddy, what does 'now formatting drive C:' mean?)
Yeah, sorry. Mono has a tendency to re-write my code as I type, even inserting new 'using' statements. It's maddening.
Thanks this helped a lot!