Search Unity

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

Question Read Collider

Discussion in 'Physics for ECS' started by shotoutgames, Oct 31, 2022.

  1. shotoutgames

    shotoutgames

    Joined:
    Dec 29, 2013
    Posts:
    283
    Hi,
    I am trying to read in the Physics collider for objects that have them so I can then set them at default.
    This has to be done at run only but I am trying to find the best method.
    I thought about a system that reads and sets but not sure if this is best.
    Thanks!
     
  2. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    857
    Not sure what you are trying to do.
     
  3. heu3becteh

    heu3becteh

    Joined:
    Aug 6, 2020
    Posts:
    25
    I am not sure either, but I get the Authoring PhysicsCollider like that in ISystem:
    Code (CSharp):
    1. foreach (var physicsCollider in SystemAPI.Query<PhysicsCollider>().WithAll<SomeTagName>())
    2. {
    3.    PhysicsColliderList.somePhysicsCollider = physicsCollider;
    4. }
    After that I add PhysicsCollider Component in SystemBase like that:
    Code (CSharp):
    1. Entities
    2.    .WithAll<SomeOtherTagName>()
    3.    .ForEach((Entity entity) =>
    4.    {
    5.        ecb.AddComponent(entity, physicsColliderLocal);
    6.    })
    7.    .Run();
    It could be SetComponent instead of AddComponent.
     
    daniel-holz and shotoutgames like this.