Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question How to get capsule collider properties from entity for capsulecast?

Discussion in 'Physics for ECS' started by AlexAdach, Jul 13, 2023.

  1. AlexAdach

    AlexAdach

    Joined:
    Jan 25, 2023
    Posts:
    29
    Hi,

    The capsulecast method requires that you define the size and shape of the capsule into the method. Is there a way to get that directly from the capsule collider on the entity?

    I've gotten this far:

    var rigidBodyIndex = collisionWorld.GetRigidBodyIndex(character.Entity);
    var collider = collisionWorld.Bodies[rigidBodyIndex].Collider;

    that gets me the BlobAssetReference<Collider>, do I then cast this in to a capsule collider type?
     
  2. AlexAdach

    AlexAdach

    Joined:
    Jan 25, 2023
    Posts:
    29
    nevermind it seems that collider.As<CapsuleCollider>() gets me to CapsuleCollider. Then I can use .Geometry.
     
  3. AlexAdach

    AlexAdach

    Joined:
    Jan 25, 2023
    Posts:
    29
    gonna piggyback off this question.

    What's the difference between CollisionWorld.CapsuleCast vs CapsuleCollider.CapsuleCast?