Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

The sides count of the CylinderCollider shape cannot be changed by scripts.

Discussion in 'Physics for ECS' started by Tigrian, Apr 6, 2022.

  1. Tigrian

    Tigrian

    Joined:
    Mar 21, 2021
    Posts:
    113
    Hi!

    I am creating a script to generate colliders, when I generate my collider using this method, everything goes well except for the sides count:
    Code (CSharp):
    1.                     collider.SetCylinder(new CylinderGeometry
    2.                     {
    3.                         Center = float3.zero,
    4.                         Orientation = parameters.orientation,
    5.                         BevelRadius = parameters.bevelRadius,
    6.                         Height = 0.4f,
    7.                         Radius = 0.4f,
    8.                         SideCount = parameters.cylinderSideCount
    9.                     });
    The number of sides counts is always 20, default value in the physic shape Authoring script (the setCylinder method never uses sides count, it appears when I read the code). The only way for me to change this value is in the editor manually. Can you confirm that this is not an error on my part, and if not what would be a possible work-around?
     
  2. papopov

    papopov

    Joined:
    Jun 29, 2020
    Posts:
    32
    upload_2022-4-7_14-10-35.png
    Unfortunately, there appears to be a bug in the PhysicsShapeAuthoring.SetCylinder() method, where the line in the red is missing from the version that you are using. I think the only thing you can do is to modify SetCylinder() and add the line in red.
    We'll fix this for the next release
     
  3. Tigrian

    Tigrian

    Joined:
    Mar 21, 2021
    Posts:
    113
    Thank you for the quick response, I'll wait for the fix.