Search Unity

Anyway to tie a Scale and PhysicsCollider component together?

Discussion in 'Entity Component System' started by forteller, Feb 11, 2020.

  1. forteller

    forteller

    Joined:
    Jun 15, 2019
    Posts:
    55
    In short, do you need to manually recreate the a PhysicsShape's Collider every time you want to update the scale of the collider?

    I'm creating a basic chunk system, and when the player clicks the mouse I need to get a NativeList back of all the chunks they're currently looking/pointing through. I have a chunk prefab with a PhysicsShape and various other gameobject components which are converted to entities/entity-components at runtime using the GameObjectConversionUtility.ConvertGameObjectHierarchy().

    It works fine if the chunks are all of unit size. But no matter what size I make the chunks by using the Scale component it seems that the colliders remain the same (unit) shape. Must colliders be manually updated (using SetComponentData....) every time the respective entity's scale changes? Is there anyway to get Unity.Physics to inherently tie Scale with PhysicsCollider component? If not, would this updating of a PhysicsColliders Value be a very slow operation even if the type and shape of the collider does not change?

    Thanks!
     
  2. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    761