Search Unity

Does PhysicsExclude should deactivate PhysicsVelocity. Is this expected?

Discussion in 'Physics for ECS' started by Antypodish, Mar 2, 2021.

  1. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,776
    I have noticed, that adding PhysicsExclude component tag, does not stop PhysicsVelocity component, to accumulate its velocities. Is this expected? How I can disable PhysicsVelocity from accumulating, without using Disable component tag?

    upload_2021-3-2_13-54-39.png
     
  2. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    Hi @Antypodish , could you please make sure that it's not one of your systems/jobs changing the PhysicsVelocity? Also, did you add PhysicsExclude component once or you're maybe adding and removing it every step?

    I just tried it by adding the following code on UnityPhysicsSamples/Assets/Demos/2. Setup/2b. Motion Properties/2b7. Motion Properties - Smoothing.unity scene and it works fine:

    Code (CSharp):
    1. using (var commandBuffer = new EntityCommandBuffer(Collections.Allocator.Temp))
    2.             {
    3.                 Entities.WithoutBurst().WithAll<PhysicsVelocity>().WithNone<PhysicsExclude>()
    4.                     .ForEach((Entity entity, in Transforms.Translation tr) =>
    5.                     {
    6.                         if (tr.Value.x < -10)
    7.                         {
    8.                             commandBuffer.AddComponent(entity, new PhysicsExclude {});
    9.                         }
    10.                     }).Run();
    11.  
    12.                 commandBuffer.Playback(EntityManager);
    13.             }
     
    Antypodish likes this.
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,776
    @milos85miki

    Hi appreciate for rapid response.
    It gave me few thoughts, to think of.
    After quick review of the code, it looks actually it is fault on my side.

    That one I am 100% sure, is not happening.

    But fault was in my systems, which used
    PhysicsComponentExtensions.ApplyAngularImpulse
    and
    PhysicsComponentExtensions.ApplyLinearImpulse

    Which was a bit weird, because linear impulse seems been not added anyway.

    But I added to these systems .WithNone <PhysicsExclude> () and that seems resolves issue.
    I will keep an eye on this behaviour however.