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. Dismiss Notice

Question How to achieve Raycast (MaxIntersection) in DOTS?

Discussion in 'Physics for ECS' started by OrientedPain, Jul 22, 2023.

  1. OrientedPain

    OrientedPain

    Joined:
    Mar 26, 2018
    Posts:
    35
    Hello everyone,

    Is there a method to achieve MaxIntersection?

    I did a system that moves the player when clicking on the ground using Raycast and custom physics tag, when I'm working on picking system that lets the player pick items from ground when click on it, but the Raycast detects both the item and the ground. How can I make the Ray only detect the item when click on it. Or how to make the Ray only intersect with only one object?

    Thanks in advance.
     
  2. Drayanlia

    Drayanlia

    Joined:
    Jan 14, 2021
    Posts:
    7
    Sounds like you are using
    CastRay(RaycastInput, ref NativeList<RaycastHit>) instead of
    CastRay(RaycastInput, out RaycastHit)

    The first one is for getting all hits while the second only returns the closest hit.
     
    OrientedPain likes this.
  3. OrientedPain

    OrientedPain

    Joined:
    Mar 26, 2018
    Posts:
    35
    Thank you so much you saved me. :)