Search Unity

Zero-gravity Rigidbody with child collider gives strange behavior

Discussion in 'Physics' started by Plystire, Oct 30, 2016.

  1. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    So, in my setup, I have a parent object with a rigidbody (NO GRAVITY) and no collider. Instead the collider is on a child of the object. Whenever this child moves within local space, this parent rigidbody changes position very slightly in a random direction (Though seems to favor positive direction). It doesn't matter how large of a movement or how small of a movement, this rigidbody moves a tiny amount every frame that the child moves. I actually have three children with colliders, but only one of them is causing the behavior. It doesn't even matter if the child collider is within the parent object. I've moved it hundreds of units away, and the same thing applies, whenever it moves, the rigidbody moves. And this becomes a problem because I'm working on a VR game, and this object is attached to the player's head.. so the object moves practically every frame, thus creating this constant random motion in space!

    When I disable the script that allows the sphere to follow the player's head, the entire rig immediately stops moving, which makes me believe this is indeed an "adjustment" Unity is making, and not some random tidbit of velocity that I'm applying in one of my scripts. (I only change the rigidbody's velocity in my scripts)

    Is this a miscalculation in Unity when the child collider changes position? Though... why does it not care about the other two child colliders moving around in local space?

    This child collider is just a plain old sphere. I had it attached as a child of the child, but after viewing this behavior, I made it a direct child like the others. The behavior persisted, and I can't figure out what's going on to make a workaround for it. :(

    I also confirm it is the collider causing the behavior, as diabling the collider alone will immediately cause the behavior to stop.

    This is very frustrating because it completely destroys free-floating. :(
    I also require the collider so that the player has collision.


    [UPDATE]
    The other two children with colliders have their own rigidbodies. This is intended, because they are the player's hands, and while they should react with the world separately, they must be part of the parent rig. However, interactions with the player's body should cause the rig itself to move, not the body locally. Putting the rigidbody on the sphere wouldn't actually effect the player. :/
     
  2. o0_ICE_0o

    o0_ICE_0o

    Joined:
    Apr 3, 2014
    Posts:
    21
    I came across a similar situation, my game object was in this order:
    RootGameObject --> ChildGameObject.

    The RootGameobject held the Rigidbody and the ChildGameObject held the colliders, when force was applied nothing happened, So i brought my colliders from the ChildGameObject to the RootGameObject then everything worked fine.
    Try changing your colliders to the root
    FYI mine was also in zero grav.
     
  3. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    Thanks for the suggestion.

    So... Because this is part of the VR rig that I use for Steam, I need this sphere to follow the child object of the main rig object. But I need the whole rig to move when this sphere collides with the world.

    I mean... it works amazingly well just making the sphere a child of the head object (which is a child of the main rig)... it just has this progressively worsening random movement that can't be stopped even by setting the rigidbody velocity to Vector3.zero.

    I tried making the sphere a direct child of the main rig and giving it a "follow the head" script. This still worked, but did not fix the problem.

    How would I go about relocating the sphere collider if it were attached to the parent object, such that it always matched the child object's local position and rotation? o_O

    I mean, is this a bug? Should I report it? It's very irritating :mad:
     
  4. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    Bump. This is still an issue in Unity 5.5.

    Is anyone aware of a way to get around this? :(