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

Resolved Raycastcommands not working against colliders in subcenes in build

Discussion in 'Physics for ECS' started by Ondrej98, Sep 21, 2023.

  1. Ondrej98

    Ondrej98

    Joined:
    Oct 18, 2016
    Posts:
    20
    Hello,

    I am using RaycastCommand.ScheduleBatch to raycast against entities with colliders in a subscene. It works perfectly in editor but for some reason it doesn't detect the raycasts in a build. What could the issue? I am using entities 1.0.0-pre.15 and physics 1.0.0-pre.15 with using 2022.3.0.
     
  2. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    282
    A few things here.

    You’re using very out of date versions of the packages and main Editor. You should update to the 1.0.16 packages and Unity Editor 2022.3.10f1.

    RaycastCommand is only for PhysX. It does not have anything to do with Unity Physics or Havok Physics. You are likely seeing this behaviour because you have a subscene open that has authoring Collider components. The correct solution is to use the CollisionWorld singleton from a system in the World the entities are contained in.
     
    daniel-holz likes this.
  3. Ondrej98

    Ondrej98

    Joined:
    Oct 18, 2016
    Posts:
    20
    Hey, thanks for the reply, I am using one version before the most current one, that doesn't seem too out of date to me. Is there any reason why RaycastCommand only works in editor though? Is there any way to make it work in build or is there any similar api using CollisionWorld?
     
  4. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    282
    This is not the case. You are using a preview release 1.0.0-pre.15 from 2022/11/16. This is nearly a year old. In between these two are:
    -1.0.0-pre.44 from 2023/02/13
    -1.0.0-pre.47 from 2023/03/01
    -1.0.0-pre.65 from 2023/03/21
    -1.0.8 from 2023/04/17
    -1.0.10 from 2023/05/23
    -1.0.11 from 2023/06/19
    -1.0.14 from 2023/07/27
    The current non-experimental release is 1.0.16 from 2023/09/11.
    It would be helpful for you to brush up on what SemVer is.
    https://semver.org/spec/v2.0.0.html

    https://docs.unity3d.com/Packages/com.unity.physics@1.0/api/Unity.Physics.CollisionWorld.html
    CastRay overloads produce raycast results for a single ray. It’s up to you how you end up doing multiple raycasts. One way could be to schedule a parallel-for job with an array of input rays and an array of output rays. That would work for single-hit collectors. Otherwise, you would likely want to use a single-thread job.

    There are many samples for using Unity Physics here.
    https://github.com/Unity-Technologi...mSamples/blob/master/PhysicsSamples/README.md
     
    Last edited: Sep 22, 2023
    daniel-holz likes this.