Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

ETA of awesome APIs

Discussion in 'Physics for ECS' started by optimise, Feb 25, 2020.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,114
    Hi @Adam-Mechtley, will this kind of awesome APIs release in next DOTS Physics package version and it will compatible with next DOTS Necode package version?

    upload_2020-2-25_11-29-47.png
     
    nicolasgramlich likes this.
  2. Adam-Mechtley

    Adam-Mechtley

    Administrator

    Joined:
    Feb 5, 2007
    Posts:
    290
    This will not be available in the next release. No concrete ETA yet. Whenever API improvements land and whatever form they ultimately take, they should ultimately be compatible with netcode, as should be expected of all features in the DOTS ecosystem
     
    nicolasgramlich and optimise like this.
  3. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,114
    Currently what's the way to do overlap sphere? Can you show me example code?

    I see DOTS Netcode 0.1.0-preview.6 has been released and it's compatible with latest Entities 0.6.0-preview.24. What is the ETA of new DOTS Physics version that is compatible with DOTS Netcode 0.1.0-preview.6 and Entities 0.6.0-preview.24?
     
    Last edited: Feb 26, 2020
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    Are they not working at the moment? They seem to work fine for me. Netcode 0.1 specifically added physics support to it for 0.2.4+
     
    optimise likes this.
  5. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,114
    DOTS Physics 0.2.5-preview.1 is working properly with latest DOTS Necode but still I think release new DOTS Physics version that has proper latest Entities package dependency is better.
     
  6. aveakrause

    aveakrause

    Joined:
    Oct 3, 2018
    Posts:
    70
    I use Calculate Distance to do it. Here it is with an explosion.
    Code (CSharp):
    1. private void CheckAndExplode(Entity entity, float3 position)
    2.         {
    3.             // If the entity doesn't explode, or it can't deal damage, get out
    4.             if(!explodeFromEntity.Exists(entity) || !damageData.Exists(entity))
    5.                 return;
    6.  
    7.             ExplodesOnCollisionComponent explosionData = explodeFromEntity[entity];
    8.             // Stores a list of all entities within the explosion radius
    9.             NativeList<DistanceHit> distanceHits = new NativeList<DistanceHit>(Allocator.Temp);
    10.             // Query the collision world for all entities within the explosion radius
    11.             physicsWorld.CollisionWorld.CalculateDistance(
    12.                 new PointDistanceInput{
    13.                     Position = position,
    14.                     MaxDistance = explodeFromEntity[entity].explosionRadius,
    15.                     Filter = new CollisionFilter{BelongsTo = ~0u, CollidesWith = ~0u}
    16.                 },
    17.                 ref distanceHits
    18.             );
    19.            
    20.             // Deal damage to anything that should take damage
    21.             for(int i = 0; i < distanceHits.Length; i++)
    22.             {
    23.                 DamageUtils.CheckAndDealDamage(
    24.                     entity, physicsWorld.CollisionWorld.Bodies[distanceHits[i].RigidBodyIndex].Entity,
    25.                     ref damageBuffer, in damageData, in teamData, time, entityCommandBuffer
    26.                 );
    27.             }
    28.  
    29.             distanceHits.Dispose();
    30.         }
     
    nicolasgramlich likes this.