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

Rigidbody physics on a convert-to-entity object does not function as expected

Discussion in 'Entity Component System' started by alexchesser, Feb 20, 2020.

  1. alexchesser

    alexchesser

    Joined:
    Sep 15, 2017
    Posts:
    147
    I'm not sure if this is a bug, but I was wondering if anyone else has seen this behavior.

    I have a number of gameobjects within a convert-to-entity subscene. They have colliders and rigidbodies on them. I expect them to fall when the game plays. Interestingly enough they do appear to fall within the scene, but not within the game itself.

    Here's a video of what I'm talking about:



    Notice how the objects within the SCENE view fall on play, but in the game view stay floating.

    Crazy right?! Perhaps that is a bug or am I doing something wrong?
     
  2. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,697
    Yes this happens to me with other functionality like gizmos and meshes. As soon as I close the sub scene everything runs normal.
     
  3. alexchesser

    alexchesser

    Joined:
    Sep 15, 2017
    Posts:
    147
    Interesting, closing the SubScene seems to make it so *at least* the scene view and the game veiw behave the same way - sadly - not the way where objects with rigidbodies fall as expected after getting converted to entities.
     
  4. Mike-Geig

    Mike-Geig

    Unity Technologies

    Joined:
    Aug 16, 2013
    Posts:
    244
    What kind of "static" are those cubes?
     
    alexchesser likes this.
  5. alexchesser

    alexchesser

    Joined:
    Sep 15, 2017
    Posts:
    147
    Ahhh - yes - those are the occluder and occludee - the sub menu didn't show up in my OBS recording. I expanded and mouse-circled the two options to point that out.

    I can try the test again tonight with those flags turned off just to be sure.

    The occlusion zone itself is flagged with "Is View Volume" which to the best of my understanding means that moving objects are can be hidden.
     
  6. Mike-Geig

    Mike-Geig

    Unity Technologies

    Joined:
    Aug 16, 2013
    Posts:
    244
    I would test with that turned off. I don't actually know what (if anything) those will map to in a DOTS conversion
     
    alexchesser likes this.
  7. alexchesser

    alexchesser

    Joined:
    Sep 15, 2017
    Posts:
    147
    OK! Thanks for confirming that it is at least expected behavior. After I get home from work and put my kid to bed I'll try again with those static-occluder settings turned off. If it still doesn't work I'll try to replicate in a fresh standalone project & file a bug report if that fails.

    Is my understanding correct in that traditional gameobjects/monobehaviors cannot interact with the DOTS/Havok Physics world?

    I'd also be happy to use the new physics systems as long as I was able to get my old style AnimationControllers in there.
     
  8. Mike-Geig

    Mike-Geig

    Unity Technologies

    Joined:
    Aug 16, 2013
    Posts:
    244
    You are correct that they will not interact. Currently the best way forward is to use a system to sync an entity's position with some "dummy" game object that just runs the animations. Otherwise, the DOTS animation system will be previewable soon.
     
    alexchesser likes this.
  9. alexchesser

    alexchesser

    Joined:
    Sep 15, 2017
    Posts:
    147
    Excellent line of questioning on the static occluder and occludee ... though I can't personally fathom why it DOES have an impact on a converted objects' behavior. It definitely does, as seen in the video below. They don't actually FIX the behavior with respect to rigidbidy collision, it's just a slightly different error.

    See the tabletop is a gameobject and now the entities fall right through instead of stopping at the collider.



    I wonder if the thing that's going on under-the-hood here is that rigidbody->entities are getting added to a unity-dots-physics space while classic rigidbodies are staying in the non-dots-physics space.

    In another test, I added the tabletop plan to a subscene of its own which resulted in the entity blocks actually stopping on the table-top. Which contributes to the multiple-physics-worlds theory.

    At the moment I'm also going to try removing the unity-physics and unity-havoc packages from the project build to see if getting rid of them lets Entities convert their rigidbodies into something that lives within the old physics world. (it's recompiling as I write this) (edit: unsurprisingly in hindsight, it didn't work)

    Alternately, figuring out how to make the dummy-gameobject follow the entity and run the animations is a pretty appealing option. I saw the DOTS animation system is up on github - but is HDRP only. https://github.com/Unity-Technologies/Unity.Animation.Samples are you expecting a LWRP version will be accessible soon?

    I'm building in VR on the oculus quest so am a little worried that HRDP isn't exactly the right tech to run on a snapdragon :)
     
    Last edited: Feb 21, 2020
  10. Mike-Geig

    Mike-Geig

    Unity Technologies

    Joined:
    Aug 16, 2013
    Posts:
    244
    Correct, DOTS Physics won't interact with Game Object physics. They are two separate systems. That's why your entities pass through your GO collider.
     
    alexchesser likes this.