Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Zero gravity issue with VR rig

Discussion in 'AR/VR (XR) Discussion' started by Plystire, Dec 4, 2016.

  1. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    Previous thread for this: https://forum.unity3d.com/threads/z...child-collider-gives-strange-behavior.438778/

    Hello, I am using the SteamVR asset to make my game.

    Everything is going well at this juncture, except for one tiny little annoyance I've been putting up with this entire time.

    My game relies on the player being in zero-G. For this, I simply have a rigidbody on the SteamVR rig and turned gravity off for it.

    Great! However, to collide the player with the environment, I have the collision body on a child object (the head) of the rig.

    Now, this works wonderfully well. Do not mistake that.

    The problem is that the child collider is causing a constant, slowly worsening, random jitter in the rig's position. I know this because disabling the collider causes the rig to stop jittering. The hands for the player have their own colliders as well, but they also have their own rigidbodies which I think prevents them from causing this behavior.

    I have isolated the issue to motion of the child within local space of the rig (containing the rigidbody). By detaching the collider from the player's head, and placing it on a stationary child object within the rig, there is NO jitter. As soon as I manually move this collider in Editor, during runtime, the rig begins to jitter.

    So, I believe this is caused by the child collider moving in local space, and forcing the physics object to update, which doesn't get the position quite right, and moves the whole rig ever so slightly. Since this is VR and the collider is attached to the player's head, it is practically always moving in local space, thus producing this constant jitter. I also fear this might be causing unnecessary processing and will be a performance hindrence. :(


    How can I fix this? It seems to be a bug from the physics engine. Very easy to replicate.
    Is there a better way for me to set this up?


    To clarify, I cannot put the collider on the parent object. It must follow the player's head, and thus must move through local space. The rigidbody must be attached to the parent object, so that the entire rig moves when the player collides with something.


    This is a huge annoyance, because the player is constantly jittering and cannot stop. After so much time has passed in-game, the jittering is so noticeable that it becomes a hindrance on gameplay itself. :mad:
     
  2. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    Set the rigidbody to kinematic?
     
  3. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    Sorry, I suppose it's not entirely obvious... the rigidbody is necessary so that velocity can be applied.
     
  4. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    Have you tried Continuous Dynamic or Dynamic collision detection?

    In my Flying/No Gravity demo I used a CharacterController instead of a rigidbody to get velocity. Have you tried using CharacterController?

    My flying demo is in this pack:
    https://www.assetstore.unity3d.com/en/#!/content/69041
     
  5. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    It already is set to Continuous Dynamic.

    If I try to use a character controller on the parent object and simply relocate the center of the collider to the player's head position in FixedUpdate... moving bodies cannot move the player. With my setup, an enemy flying into the player will push them backward. That's the desired effect. That is the effect I achieved... and then there's this bug...

    I've opened a bug report... I gave very simple instructions to replicate the problem... and then even gave two short videos demonstrating how to produce the problem from a fresh unity scene, because apparently my written instructions were insufficient for replication. :confused:
     
  6. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142