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 Raycst a specific collider

Discussion in 'Physics for ECS' started by argibaltzi, Jan 1, 2023.

  1. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    Hi

    Is it possible in dots to raycast a specific collider to see if that object intersects?

    The gameobject physics have a collider.RayCast function but i can't find any dots

    Thanks!
     
  2. calabi

    calabi

    Joined:
    Oct 29, 2009
    Posts:
    232
    You should look in the Unity Physics samples but it involves you getting the colliderworld and then something like this.

    if (collisionWorld.CastRay(RayInput, ref RaycastHits))

    You would also have to arrange the collision filters correctly, and there might be a problem where if the physics shapes are overlapping the CastRay will return all the hits no matter the filter and you might have to identify the specific object with a tag or something(I don't know if thats changed or not yet).