Search Unity

Question Does any documentation for unity dots physics besides the package manual exist?

Discussion in 'Physics for ECS' started by aaarrrlll, Dec 31, 2020.

  1. aaarrrlll

    aaarrrlll

    Joined:
    Dec 29, 2020
    Posts:
    8
    I am trying to find a list of the properties of a collider from unity dots physics. I specificly need to find the bounds of a capsule collider. This has proved quite hard, because all the documentation i have is this, which just provide an general overview.

    Is there any comprehensive list like the scripting api for ecs, or do i just have to try using whatever names seems most logical? If the latter is the case, do you know what the bounds of a capsule collider is called?
     
  2. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Mostly have to look through unit tests or the source to discover some of this. The physics debugging code has a lot of good stuff on introspecting collider data.

    Here is a helper to get the Aabb of a collider.
    Code (csharp):
    1.  
    2. public static unsafe bool TryGetAabbFromCollider(Collider* collider, float3 position, quaternion rotation, out Aabb aabb)
    3.         {
    4.             RigidTransform colliderTransform = new RigidTransform(rotation, position);
    5.  
    6.             switch (collider->Type)
    7.             {
    8.                 case ColliderType.Box:
    9.                     aabb = ((BoxCollider*)collider)->CalculateAabb(colliderTransform);
    10.                     return true;
    11.                 case ColliderType.Triangle:
    12.                 case ColliderType.Quad:
    13.                 case ColliderType.Cylinder:
    14.                 case ColliderType.Convex:
    15.                     aabb = ((ConvexCollider*)collider)->CalculateAabb(colliderTransform);
    16.                     return true;
    17.                 case ColliderType.Sphere:
    18.                     aabb = ((SphereCollider*)collider)->CalculateAabb(colliderTransform);
    19.                     return true;
    20.                 case ColliderType.Capsule:
    21.                     aabb = ((CapsuleCollider*)collider)->CalculateAabb(colliderTransform);
    22.                     return true;
    23.                 case ColliderType.Mesh:
    24.                     aabb = ((MeshCollider*)collider)->CalculateAabb(colliderTransform);
    25.                     return true;
    26.                 case ColliderType.Terrain:
    27.                     aabb = ((TerrainCollider*)collider)->CalculateAabb(colliderTransform);
    28.                     return true;
    29.             }
    30.  
    31.             aabb = default;
    32.             return false;
    33.         }
    34.  
     
    milos85miki and aaarrrlll like this.
  3. aaarrrlll

    aaarrrlll

    Joined:
    Dec 29, 2020
    Posts:
    8
    Thank you, you mentioned the source, where can i find that?
     
  4. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Under the Packages folder in your Project view.
     
    aaarrrlll likes this.
  5. aaarrrlll

    aaarrrlll

    Joined:
    Dec 29, 2020
    Posts:
    8
    Thanks a lot again.
     
  6. aaarrrlll

    aaarrrlll

    Joined:
    Dec 29, 2020
    Posts:
    8
    In case anyone runs into to the same problem, ended up finding a scripting api like the one for ecs. Here it is: https://docs.unity3d.com/Packages/com.unity.physics@0.5/api/

    It doesn't appear in google's search results, but can be found by manually changing the url adress of the physics manual.
     
    ashton_dev and milos85miki like this.