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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question is CapsulecastCommand working?

Discussion in 'Physics' started by Volbran, Jun 27, 2022.

  1. Volbran

    Volbran

    Joined:
    Feb 24, 2020
    Posts:
    16
    Hi everyone
    subj

    var results = new NativeArray<RaycastHit>(20, Allocator.TempJob);//in example Temp, but Temp thow Exc
    var commands = new NativeArray<CapsulecastCommand>(1, Allocator.TempJob);//--

    Vector3 point1 = Vector3.up * -0.5f;
    Vector3 point2 = Vector3.up * 0.5f;
    Vector3 direction = Vector3.forward;
    float r = 0.5f;

    RaycastHit[] hits = Physics.CapsuleCastAll(point1, point2, r, direction, 1f);//for check

    commands[0] = new CapsulecastCommand(point1, point2, r, direction, 1f);
    var handle = CapsulecastCommand.ScheduleBatch(commands, results, 1, default(JobHandle));
    handle.Complete();

    RaycastHit batchedHit = results[0];

    results.Dispose();
    commands.Dispose();

    hits has 4 members
    results no members(all colliders null)

    what am i doing wrong? how to get hits?
     
  2. Volbran

    Volbran

    Joined:
    Feb 24, 2020
    Posts:
    16
    work
    but where CapsulecastAllCommand? :)))