Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Polygon Collider dynamic modification

Discussion in 'DOTS Physics' started by RBogdy, Feb 6, 2020.

  1. RBogdy

    RBogdy

    Joined:
    Mar 6, 2019
    Posts:
    60
    Hello,

    Is there any way possible to modify a Quad Polygon Collider to get the similar behavior from the 'ChangeSphereColliderRadius' Physics example?

    I see that the vertices can only be read and not written to.

    Is there a way to have my collider updated to new vertices? I want to have a 'plane' stretched between 2 objects acting as a trigger for collisions checking objects that pass between these. The thing is these entities might update their position (i.e: 1 might be on top of a moving platform) and I want the collider to stretch and squeeze as the distance between the entities increases or decreases.

    Any ideas?
     
  2. Rory_Havok

    Rory_Havok

    Joined:
    Jun 25, 2018
    Posts:
    70
    Not out of the box, but you could tweak the source to make PolygonCollider.SetAsQuad() public and call that. The key thing is you would need to ensure that the vertices you provide to that function are coplanar and ordered so that they walk around the perimeter.
     
  3. RBogdy

    RBogdy

    Joined:
    Mar 6, 2019
    Posts:
    60
    Thank you @Rory_Havok !

    Is there a reason why we are not getting this as an out of the box method of changing the Geometry as we can for Sphere or Box colliders ?
     
  4. Rory_Havok

    Rory_Havok

    Joined:
    Jun 25, 2018
    Posts:
    70
    No strong reason, it just hasn't come up yet. I'll log it.

    Note that an API for quads (or polygons in general) is a little trickier than box or sphere because there is no parametric definition - users would have to specify vertices directly and therefore understand and respect the co-planar requirement.
     
unityunity