Search Unity

Question Best approach for scaling collider

Discussion in 'Physics for ECS' started by Kowarenai, Feb 15, 2021.

  1. Kowarenai

    Kowarenai

    Joined:
    May 27, 2019
    Posts:
    14
    As part of the software I'm developing, I need to allow users to change the uniform scale of objects at runtime, and have the colliders be scaled/regenerated with the mesh (similarly to how this would work when scaling a gameobject in unity). I had a little try with this a while ago, and the collider seemed to scale with the rendermesh when it was a sphere, but not when set to a convex hull.

    Only a few objects will be scaled at a time, so I'm not worried about having the collider scaling be fast.

    Is there currently a way of doing this, ideally without using unsafe code? Thanks for any advice.
     
    Last edited: Feb 15, 2021
  2. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    as far as i know when changing colliders you need to recreate the collider and the physics mass components
    there is some way using unsafe code to change the collider size, but you are entering grey area
     
    milos85miki likes this.
  3. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    Last edited: Feb 18, 2021
    NotaNaN likes this.
  4. Kowarenai

    Kowarenai

    Joined:
    May 27, 2019
    Posts:
    14
    I'm thinking that it might be wise to delay this feature in my project until the very end in the hope that Unity adds a safe and performant way of doing it before release.
     
  5. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    We will be looking into this in the coming releases. No concrete timelines yet, but it's high on our list.
     
    NotaNaN likes this.