Search Unity

An unusual case that CharacterController throw AssertionException

Discussion in 'Physics for ECS' started by filod, Feb 16, 2020.

  1. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    224
    when my character stuck here:
    upload_2020-2-16_21-20-22.png
    stack trace:

    upload_2020-2-16_21-22-18.png
     
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Hey, it would be great if you could provide the input to the CollideAndIntegrate() call (stepInput, characterMass, transform and linearVelocity) for us to look into it with more details.

    Some character fixes are scheduled for the next release and some of them are targeting this sort of scenarios, but I'd like to be sure.
     
    andywatts likes this.
  3. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    224
    LinearVelocity is NaN could be the causing, hope this help:
    upload_2020-2-18_21-48-22.png
     
  4. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Great, we will need to unroll this further. Can you find out what produces these NaN values in the LinearVelocity? My guess is that it's CalculateMovement() method. Especially if the state is Supported while surfaceNormal is (0,0,0). Let me know and I can provide you with a workaround until the fix is released!
     
  5. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    224
    Yes, you are right about zero-surfaceNormal.
     
  6. linfuqing

    linfuqing

    Joined:
    May 11, 2015
    Posts:
    166
  7. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Exactly, use @linfuqing's modify 3 and it will go away. This is fixed in the coming release.
     
    Sima_Havok and filod like this.
  8. andywatts

    andywatts

    Joined:
    Sep 19, 2015
    Posts:
    112
    I'm also getting an AssertionException from CheckSupport.

    CollideAndIntegrate inputs are...
    stepInput: CharacterControllerUtilities+CharacterControllerStepInput
    linearVelocity: float3(0f, -3.279998f, 0f)
    transform: RigidTransform((0f, -0.2615776f, 0f, -0.9651824f), (0f, 8.653604f, 0f))
    characterMass: 1

    CheckSupport output are...
    stepInput: CharacterControllerUtilities+CharacterControllerStepInput
    surfaceNormals: float3(0f, 0f, 0f)
    supportedState:Unsupported
    surfaceVelocity:float3(0f, 0f, 0f)


    The error throws when the falling ball hits meshCollider.
    The ball is standard conversion with shape and kinematic body.
    The mesh collider is created with...

    Code (CSharp):
    1.  
    2. CollisionFilter filter = new CollisionFilter
    3.             {
    4.                 BelongsTo = ~0u,
    5.                 CollidesWith = ~0u,
    6.                 GroupIndex = 0
    7.             };
    8.              var meshCollider = Unity.Physics.MeshCollider.Create(vertices.AsArray(), triangles.AsArray(), filter);
    9.             var physicsCollider = new Unity.Physics.PhysicsCollider { Value = meshCollider };
    10.             PostUpdateCommands.AddComponent<PhysicsCollider>(entity, physicsCollider)
    11.  
    I tried's linfuqing's MODIFY 3, but no change.
    Not seeing NaN's anywhere.

    I'm using the code form the ECSSamples repo.
    DOTSample looks newer, but coupled to netcode work.
     
  9. andywatts

    andywatts

    Joined:
    Sep 19, 2015
    Posts:
    112
    Update.
    No errors when doing the regular ConvertToEntity workflow with PhysicsShapeAuthoring component.
    However, it throws with a custom MeshCollider like below...

    Code (CSharp):
    1.  
    2. public class CustomMeshColliderSystem : ComponentSystem
    3. {
    4.  
    5.     protected override void OnUpdate() {}
    6.  
    7.  
    8.     protected override void OnCreate()
    9.     {
    10.         EntityManager em = World.Active.EntityManager;
    11.         Entity e = em.CreateEntity();
    12.  
    13.         CollisionFilter filter = new CollisionFilter
    14.         {
    15.             BelongsTo = ~0u,
    16.             CollidesWith = ~0u,
    17.             GroupIndex = 0
    18.         };
    19.  
    20.         NativeList<float3> verts = new NativeList<float3>(Allocator.Temp);
    21.         verts.Add(new float3(-4, 0, -4));
    22.         verts.Add(new float3(4, 0, -4));
    23.         verts.Add(new float3(-4, 0, 4));
    24.         verts.Add(new float3(4, 0, 4));
    25.  
    26.         NativeList<int3> tris = new NativeList<int3>(Allocator.Temp);
    27.         tris.Add(new int3(0, 2, 1));
    28.         tris.Add(new int3(2, 3, 1));
    29.  
    30.         var meshCollider = Unity.Physics.MeshCollider.Create(verts.AsArray(), tris.AsArray(), filter);
    31.         var collider = new Unity.Physics.PhysicsCollider { Value = meshCollider };
    32.         em.AddComponentData<PhysicsCollider>(e, collider);
    33.  
    34.         em.AddComponentData<LocalToWorld>(e, new LocalToWorld { Value = new float4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) });
    35.         em.AddComponentData<Translation>(e, new Translation {});
    36.         em.AddComponentData<Rotation>(e, new Rotation {});
    37.  
    38.     }
    39.  
    40. }
     
  10. andywatts

    andywatts

    Joined:
    Sep 19, 2015
    Posts:
    112
    Found the problem.
    I wasn't correctly initialising Transform and Rotation components with Values.
    All good now.
     
    petarmHavok likes this.