- Home /
 
Spirit Level for object in VR
I've looked into the Gyroscope class that Unity has, but I'm not sure if I can implement this for my purposes. I need to have a level that detects slight movement and moves in the opposite direction of gravity like it would realistically. I am working in VR and not a phone, so I need a device in-world to have the functionality of the gyroscope. 
 
 I currently have the negative effect of gravity applying a force to the spirit level "Bubble" which works but only in extreme cases - if I turn the object fully sideways it moves, but I need it to be able to detect smaller movements on the X and Z planes (and move in the opposite direction of gravity). 
 
 This is what I have so far:
     private void Start()
     {
         spiritLev = this.GetComponent<Rigidbody>();
         gravity = Physics.gravity;
         parent = GetComponentInParent<Transform>();
     }
 
     private void FixedUpdate()
     {
         spiritLev.useGravity = false;
         spiritLev.AddForce(gravityForce * gravity, ForceMode.Force);
         transform.position = new Vector3(transform.position.x, parent.transform.position.y, transform.position.z); 
      }
 
               Any help or insight would be greatly appreciated!
Your answer
 
             Follow this Question
Related Questions
(Steam VR / Vive) Rigidbody moving in only one direction after collision 1 Answer
Wall Running using Javascript 0 Answers
Curious about "Vortex" force (HELP) 2 Answers
Revolver cylinder physics 0 Answers
how to make Oculus Touch door opening 0 Answers