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

Multi-hit versions of physics cast commands

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

  1. XaneFeather

    XaneFeather

    Joined:
    Sep 4, 2013
    Posts:
    97
    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

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    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