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?
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.
public static unsafe bool TryGetAabbFromCollider(Collider* collider, float3 position, quaternion rotation, out Aabb aabb)
{
RigidTransform colliderTransform = new RigidTransform(rotation, position);
switch (collider->Type)
{
case ColliderType.Box:
aabb = ((BoxCollider*)collider)->CalculateAabb(colliderTransform);
return true;
case ColliderType.Triangle:
case ColliderType.Quad:
case ColliderType.Cylinder:
case ColliderType.Convex:
aabb = ((ConvexCollider*)collider)->CalculateAabb(colliderTransform);
return true;
case ColliderType.Sphere:
aabb = ((SphereCollider*)collider)->CalculateAabb(colliderTransform);
return true;
case ColliderType.Capsule:
aabb = ((CapsuleCollider*)collider)->CalculateAabb(colliderTransform);
return true;
case ColliderType.Mesh:
aabb = ((MeshCollider*)collider)->CalculateAabb(colliderTransform);
return true;
case ColliderType.Terrain:
aabb = ((TerrainCollider*)collider)->CalculateAabb(colliderTransform);
return true;
}
aabb = default;
return false;
}
2 Likes
Thank you, you mentioned the source, where can i find that?
Under the Packages folder in your Project view.
1 Like
In case anyone runs into to the same problem, ended up finding a scripting api like the one for ecs. Here it is: | Unity Physics | 0.5.1-preview.2
It doesn’t appear in google’s search results, but can be found by manually changing the url adress of the physics manual.
2 Likes