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

Question World.CalculateDistance, dynamic filtering

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

  1. rivFox

    rivFox

    Joined:
    Nov 16, 2016
    Posts:
    6
    Hi!
    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.