Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question World.CalculateDistance, dynamic filtering

Discussion in 'Physics for ECS' started by rivFox, Aug 10, 2022.

  1. rivFox


    Nov 16, 2016
    I want to find the closest entity from some point. I used
    Code (CSharp):
    1. World.CalculateDistance(pointDistanceInput, out DistanceHit hit);
    in job and it works great.

    But I want to search for the closest entity from entities containing a specific tag. How can I do that?
    1. I can find the list of all entities and then find the closest that contains the tag
    2. I can use CollisionFilter and set a layer instead of a tag. But what is the best way to change a layer in runtime?
    bb8_1 likes this.