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.
How to align the game objects in front of you?
On Reset and on Start I am attempting to have a body I created in Origin appear in front of me. I created 3 bars and attach the following code to each of them. The general idea is storing the location parameter and in OnReset function put them back to original place. All the cubes belongs to a same collection. And they are well aligned with each other in default. The result is the 3 bars appear misaligned with each other. The third bar always shows an angle with respect to other bars. That's wield because they share the same code.
using UnityEngine;
public class SphereCommands : MonoBehaviour
{
Vector3 originalLocPosition;
// Use this for initialization void Start() { // Grab the original local position of the sphere when the app starts. originalLocPosition = this.transform.localPosition; if (!this.GetComponent<Rigidbody>()) { var rigidbody = this.gameObject.AddComponent<Rigidbody>(); rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous; } } // Called by GazeGestureManager when the user performs a Select gesture void OnSelect() { // If the sphere has no Rigidbody component, add one to enable physics. if (!this.GetComponent<Rigidbody>()) { var rigidbody = this.gameObject.AddComponent<Rigidbody>(); rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous; } } // Called by SpeechManager when the user says the "Reset world" command void OnReset() { // If the sphere has a Rigidbody component, remove it to disable physics. //var rigidbody = this.GetComponent<Rigidbody>(); //if (rigidbody != null) //{ // DestroyImmediate(rigidbody); //} // reset the bar position and make it with rigidbody this.transform.localPosition = originalLocPosition; if (!this.GetComponent<Rigidbody>()) { var rigidbody = this.gameObject.AddComponent<Rigidbody>(); rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous; } // Put the sphere back into its original local position. } // Called by SpeechManager when the user says the "Drop sphere" command void OnDrop() { // Just do the same logic as a Select gesture. OnSelect(); }
};
Best Answers
-
Optionsahillier mod
@ACstudent,
If your objects are being affected by physics, then their rotations are probably changing. You'll need to save off their original rotation and then restore it in your OnReset method, just like you do with position.5
Answers
@ACstudent,
If your objects are being affected by physics, then their rotations are probably changing. You'll need to save off their original rotation and then restore it in your OnReset method, just like you do with position.
Thank you. It works.