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.

Multi-hit versions of physics cast commands

Discussion in 'Physics for ECS' started by XaneFeather, Sep 24, 2019.

  1. XaneFeather


    Sep 4, 2013
    Hello there!

    While writing a tool that required a lot of Spherecasts to determine what objects surround other objects, I looked into the job commands for physics casts to see if I can parallelize that aspect. However, I noticed that while there is a multi-hit version of RaycastCommand (maxHit parameter), Spherecast, Boxcast and Capsulecast only support single-hit results.

    Are there any plans to add multi-hit support for the other casts?
  2. Abbrew


    Jan 1, 2018
    The multi-hit property of RaycastCommand does not work. However, the experimental Unity.Physics package offers an API that has multi-hit queries. The method I believe is CollisionWorld.CastX(XInput input, ref NativeList<XHit> allHits). It seems to fill the NativeList with all hits whether it's a raycast or spherecast. Hope this helps