Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Entity disappearing? My fault, everything's fine.

Discussion in 'Physics for ECS' started by Kmsxkuse, Jan 25, 2020.

  1. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    304
    As they say, fix one bug, two more show up. Now, entities with a moderate amount of impulses applied to it (771 in the following gif per fixed update frame) disappears after a period of time whereas the rigidbody version remains stable.

    The period of time in which the ball position remains a valid number (not NaN) seems to depend on what is selected in the editor inspector. Selecting nothing very slightly extends the lifetime of the entity by roughly a second before disappearing but does not stop the effect.

    From a very surface level debugging attempt, I believe the source of the disappearence is the random failure of LocalToWorld component of the sphere. The local values are readonly components of the entity and are combined with LocalToWorld using
    var globalPosition = math.transform(LocalToWorld, LocalPosition)
    . LocalToWorld is similarly a readonly value and never modified within my system. However, once it nulls out, the entity disappears.

    Exact code here: https://github.com/Kmsxkuse/ProjectBoxes/blob/master/Assets/Scripts/BuoyancySystem.cs#L166

    Anyone have any idea? Googling this problem doesnt show anything similar in the DOTS forums.

     
    Last edited: Jan 25, 2020
  2. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    304
    H̶o̶u̶r̶s̶ ̶o̶f̶ ̶i̶n̶j̶e̶c̶t̶i̶n̶g̶ ̶t̶e̶s̶t̶ ̶j̶o̶b̶s̶ ̶a̶n̶d̶ ̶g̶r̶a̶p̶h̶i̶n̶g̶ ̶v̶a̶l̶u̶e̶ ̶c̶h̶a̶n̶g̶e̶s̶ ̶l̶a̶t̶e̶r̶,̶ ̶I̶ ̶t̶h̶i̶n̶k̶ ̶I̶ ̶g̶o̶t̶ ̶i̶t̶.

    T̶h̶e̶r̶e̶ ̶i̶s̶ ̶n̶o̶t̶h̶i̶n̶g̶ ̶w̶r̶o̶n̶g̶ ̶w̶i̶t̶h̶ ̶E̶C̶S̶/̶D̶O̶T̶S̶ ̶P̶h̶y̶s̶i̶c̶s̶ ̶(̶a̶l̶t̶h̶o̶u̶g̶h̶ ̶e̶v̶e̶n̶ ̶w̶h̶e̶n̶ ̶r̶u̶n̶n̶i̶n̶g̶ ̶t̶h̶e̶ ̶s̶y̶s̶t̶e̶m̶ ̶i̶n̶ ̶a̶ ̶h̶e̶l̶p̶e̶r̶ ̶m̶o̶n̶o̶ ̶b̶o̶o̶t̶s̶t̶r̶a̶p̶ ̶s̶c̶r̶i̶p̶t̶ ̶F̶i̶x̶e̶d̶ ̶u̶p̶d̶a̶t̶e̶,̶ ̶D̶O̶T̶S̶ ̶P̶h̶y̶s̶i̶c̶s̶ ̶u̶p̶d̶a̶t̶e̶ ̶m̶o̶v̶e̶m̶e̶n̶t̶ ̶o̶n̶e̶ ̶f̶r̶a̶m̶e̶ ̶f̶a̶s̶t̶e̶r̶ ̶t̶h̶a̶n̶ ̶R̶i̶g̶i̶d̶b̶o̶d̶y̶ ̶p̶h̶y̶s̶i̶c̶s̶)̶.

    R̶a̶t̶h̶e̶r̶ ̶t̶h̶e̶ ̶p̶r̶o̶b̶l̶e̶m̶ ̶e̶x̶i̶s̶t̶s̶ ̶w̶i̶t̶h̶ ̶B̶u̶r̶s̶t̶ ̶a̶n̶d̶ ̶P̶h̶y̶s̶i̶c̶s̶V̶e̶l̶o̶c̶i̶t̶y̶.̶A̶p̶p̶l̶y̶I̶m̶p̶u̶l̶s̶e̶(̶)̶.

    J̶u̶s̶t̶ ̶a̶n̶ ̶P̶S̶A̶ ̶f̶o̶r̶ ̶t̶h̶o̶s̶e̶ ̶u̶s̶i̶n̶g̶ ̶t̶h̶e̶ ̶P̶h̶y̶s̶i̶c̶s̶V̶e̶l̶o̶c̶i̶t̶y̶.̶A̶p̶p̶l̶y̶I̶m̶p̶u̶l̶s̶e̶(̶)̶ ̶e̶x̶t̶e̶n̶s̶i̶o̶n̶ ̶m̶e̶t̶h̶o̶d̶ ̶(̶h̶a̶v̶e̶n̶t̶ ̶t̶e̶s̶t̶e̶d̶ ̶t̶h̶e̶ ̶o̶t̶h̶e̶r̶ ̶m̶e̶t̶h̶o̶d̶s̶)̶,̶ ̶t̶h̶e̶y̶ ̶d̶o̶ ̶n̶o̶t̶ ̶w̶o̶r̶k̶ ̶w̶i̶t̶h̶ ̶[̶B̶u̶r̶s̶t̶C̶o̶m̶p̶i̶l̶e̶]̶ ̶t̶a̶g̶ ̶o̶n̶ ̶t̶h̶e̶ ̶j̶o̶b̶.̶ ̶B̶u̶r̶s̶t̶ ̶s̶o̶m̶e̶h̶o̶w̶ ̶c̶o̶r̶r̶u̶p̶t̶s̶ ̶t̶h̶e̶ ̶L̶o̶c̶a̶l̶T̶o̶W̶o̶r̶l̶d̶ ̶m̶a̶t̶r̶i̶x̶ ̶i̶n̶ ̶i̶t̶s̶ ̶o̶p̶t̶i̶m̶i̶z̶a̶t̶i̶o̶n̶.̶

    Nevermind, I was wrong. Upping the triangles count to 5000 in a full boat model once again disappears. More debugging is needed.
     
    Last edited: Jan 29, 2020
  3. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    304
    Ah, seems like I F***ed up. Error originated from math.acos(0.1/0.1) resulting not in 0 rads but NaN rads.

    Lesson learned, place a check following any math.acos() functions to check for NaN and manually set it to 0.

    Good to know.