Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Ho do I create a DOTS Trigger PhysicsCollider at run time?

Discussion in 'Physics Previews' started by Ryuuguu, Jan 30, 2020.

  1. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    391
    I can create a non trigger PhysicsCollider at runtime using

    Code (CSharp):
    1. PhysicsCollider {Value = Unity.Physics.SphereCollider.Create(
    2.                             new SphereGeometry {
    3.                                 Center = float3.zero,
    4.                                 Radius = 8,
    5.                             }, CollisionFilter.Default, Material.Default
    6. )});
    7.  
    But I do not know how to make a new physics Material with IsTrigger set.

    [edit] my bad it is easy.
    Code (CSharp):
    1. new Material{Flags = Material.MaterialFlags.IsTrigger}
     
    Last edited: Jan 30, 2020
  2. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    This post might be useful for you if you want to tweak the Material at runtime as well.