Search Unity

How to create dynamic body and collider from mesh in code?

Discussion in 'Physics for ECS' started by pbhogan, Feb 15, 2022.

  1. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I'm creating ECS entities purely in code from procedurally generated meshes and I want to add DOTS Physics components.

    How do I create the relevant PhysicsCollider, PhysicsMass, PhysicsVelocity, etc. components from this mesh in code? Is there an example somewhere of how to do this?

    I've been delving into the authoring components and it looks like a rather complex process. It sure would be nice to have some helper functions that take a mesh and produce the components needed.
     
    Last edited: Feb 15, 2022
  2. StickyKevin

    StickyKevin

    Joined:
    Jul 1, 2020
    Posts:
    22