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

Unity Tiny - 2D physics Issue

Discussion in 'Project Tiny' started by Rangerz132, May 20, 2021.

  1. Rangerz132

    Rangerz132

    Joined:
    Feb 3, 2019
    Posts:
    38
    Hi Eveybody!

    I have some issues with the the 2D physics using Unity Tiny.

    Some of my entities have a Box Collider 2D component, I would like to remove them dynamicly via scripts. In order to do it, I simply do:

    Code (CSharp):
    1. Entities.ForEach((ref Entity entity, ref Column column) =>
    2. {
    3.    EntityManager.RemoveComponent<PhysicsColliderBlob>(entity);
    4. }).WithStructuralChanges().Run();
    However, when I want to re-add a box Collider 2D to them, I don't know how to do it. If I copy the exact same code but with AddComponent<> instead of RemoveComponent<>, it does'nt work.

    Can somebody help me? Thanks
     
  2. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    For this I usually use entity command buffers instead where it doesn’t require structural changes, is bursted and can be scheduled in parallel.
    I haven’t tried the Physics 2D but I’m pretty sure you have to proper build that collider blob for it to work.
    Are you receiving any error?