#My SphereCastAll in job work uncorrectly

1 messages · Page 1 of 1 (latest)

upbeat spruce
#

Am i doing correctly ? the sphereCastHits length is always 0. it hitted nothing.

    {
        public CollisionFilter filter;
        public float neighbourRadius;
        public void Execute(ref FlockAgent flockAgent, in LocalTransform localTransform, in PhysicsWorldSingleton physicsWorldSingleton)
        {
            NativeList<ColliderCastHit> sphereCastHits = new NativeList<ColliderCastHit>(Allocator.TempJob);
            var resultOfSphereCast = physicsWorldSingleton.SphereCastAll(
                    localTransform.Position,
                    neighbourRadius,
                    float3.zero,
                    0,
                    ref sphereCastHits,
                    filter
                );
            flockAgent.neighbourCount = sphereCastHits.Length;
        }
    }```
last creek
#

what's your collision filter set to

#

wait do you have a distance of 0?

#

I think you're looking for OverlapSphere

#

not a cast

upbeat spruce
last creek
#

wait hang on

#

public void Execute(ref FlockAgent flockAgent, in LocalTransform localTransform, in PhysicsWorldSingleton physicsWorldSingleton)

#

this doesn't work

#

your flockagent doesn't have PhysicsWorldSingleton on it

#

you need to pass that in separately to the job

upbeat spruce
#

oh yes, thanks. i will fix it

last creek
#
public partial struct CheckNeighbourJob : IJobEntity
    {
        public CollisionFilter filter;
        public float neighbourRadius;
        public PhysicsWorld physicsWorld;

        public void Execute(ref FlockAgent flockAgent, in LocalTransform localTransformn)```
#

physicsWorld = SystemApi.GetSingleton<PhysicsWorldSingleton>().PhysicsWorld