Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Different collision results on Windows with nVidia GPU (2017.3.f3)

Discussion in 'Physics' started by sergioabril, Jun 27, 2018.

  1. sergioabril

    sergioabril

    Joined:
    Jan 11, 2016
    Posts:
    33
    Hi all,

    We are testing beta builds of our game, and one user suddenly reported a bug that we had not experienced yet on any platform (and that we are absolutely unable to reproduce). But he finds it consistently. Every time.

    Two elements (with kinematic rigidbodies and trigger Sphere Colliders) should make contact after moving their transforms manually, and they do for us, but not for him. The thing is that it works well on mac, on mobile, and even on other regular windows 10 setups we have tried. However, on his specific setup, for some reason, these triggers are not registering contact. And we've seen in video.

    Both triggers have kinematic rigidbodies, constrained movements and rotations, and are set to interpolate and to continuous-dynamic. Maybe it's importante to say that each one of these two is also inside their respective parent gameobject (which has another trigger on a different layer, another rigidbody, etc).

    The reason I'm saying this, since I know it's impossible for you to help us track that bug without code, is to know whether there is any known bug with physics on windows or nvidia (?) or whatever.

    His setup is:

    Windows 10 64bits
    Nvidia GTX1070
    Intel i7-7700

    The compilation is build on Unity 2017.3.1f1

    - Any known bug on physics under this Unity version? Or anything I can double-check, that could be failing only on one specific setup?

    - Is there any software that could be modifying the physics engine of the build? does the GPU driver affect to the simulation? what should we be looking at that could impact physics simulation?

    Thanks!
     
    Last edited: Jun 27, 2018
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,117
    You're moving the transforms, rather than calling Rigidbody.MovePosition? I would generally expect inconsistent simulation results by manually changing the transform an object with a rigidbody.
     
  3. sergioabril

    sergioabril

    Joined:
    Jan 11, 2016
    Posts:
    33
    Yes, and maybe it's related to that (however it's weird that's only happening there, and it's working fine on the rest)

    The reason I'm doing it though is because what I'm really moving with transforms is a parent gameobject (with no rigidbodies or colliders on it) that contains this trigger as a child. The only reason I added a rigidbody to this trigger is because it's technically moving (it's not static), even though I'm not moving it but maybe I got it wrong.

    Think of this parent object I move with transforms as an elevator (no physics involved), and these triggers as children gameObjects used as sensors on different sides of the elevetor, to trigger events when they detect a contact. I'm probably still doing something wrong, but I thought that I could (to some extent) move kinematic rigidbody's this way. (The truth is that I don't want physics at all on this movement, just transform movements with trigger events, but since these colliders are "moving", I added rigidbody's). I guess I'm still confused about how to properly move triggers and colliders with no physics involved:oops:


    Note: all objects involved here are kinematic, no real physics are being used.
     
    Last edited: Jun 28, 2018
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,428
    I can't tell why the issue appears only in such specific cases. But I can describe the reliable way for kinematic rigidbodies to detect contacts properly:
    • Use MovePosition and MoveRotation in the rigidbody. Even if there's some parenthood relationship involved, you must use this method whenever the rigidbody must move. You may compute the world position / rotation based on an offset to a parent, or any other way that fits your case
    • Enable all contact pairs in the Physics Manager. This ensures the kinematic rigidbodies always generate the proper contacts, including the continuous-dynamic cases.

      upload_2018-6-28_11-48-54.png
     
    sergioabril likes this.
  5. sergioabril

    sergioabril

    Joined:
    Jan 11, 2016
    Posts:
    33
    Thank you for that, I didn't know about contact pairs (is this something new? I didn't recall seeing it before, I jumped a few weeks ago from 5.5 to 2017.3.1). It was set to default (which means what exactly?)

    Regarding the use of MovePosition instead of transforms, does this mean that I should add a rigidbody to the parent object of the trigger (the one I'm moving right now with transfoms) and move it that way?

    Thanks for the explanations!
     
  6. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,428
    Without fully understanding your case (I find it difficult without some pictures) then I'd say yes. Anything moved explicitly by you that needs to detect collisions and contacts should be a kinematic rigidbody and be moved via MovePosition and MoveRotation. Otherwise, you may face the situation where a contact that should occur when moving the object from A to B doesn't happen because the object that should be contacted was in a middle point.
     
    sergioabril likes this.
  7. sergioabril

    sergioabril

    Joined:
    Jan 11, 2016
    Posts:
    33
    Thank you so much for your explanation; got it.

    Just one last thing. I had made (an apparently totally wrong assumption) regarding constrains and kinematic rigidbody's, maybe because I read it somewhere, or maybe because I thought it was working form me, I don't know. I was enabling all the movement and rotation constrains (on those rb flagged as kinematic), and for some reason, when moving them using transforms, this "constrains thing" improved accuracy and contact detection. Maybe it was just coincidence. But now, I've noticed by using MovePosition() that if I don't disable constrains, I can't move them at all, so I guess my constrains thing didn't make any sense.

    So here it is my last question regarding all this mess I made myself. Do constrains affect kinematic rigidbody's at all?
     
  8. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,428
    I haven't tested constrains with kinematic rigidbodies (never had to do it so far), but as for what you say, constrains work as intended in kinematic rigidbodies. The difference is that now you're moving them in the correct way, so the physics can apply the constrains.
     
    sergioabril likes this.