Why i cant send a ray like this ?

 private BuildPhysicsWorld buildPhysicsWorld;
    private CollisionWorld collisionWorld;
   
    protected override void OnStartRunning()
    {
        buildPhysicsWorld = World.DefaultGameObjectInjectionWorld.GetExistingSystem<BuildPhysicsWorld>();
        collisionWorld = buildPhysicsWorld.PhysicsWorld.CollisionWorld;
    }
   
    protected override void OnUpdate()
    {
        float xValue = Input.GetAxis("Horizontal");
        float zValue = Input.GetAxis("Vertical");

        Vector3 direction = new Vector3(xValue, 0, zValue);
        bool isInputAvaliable = direction.magnitude > 0 ? true : false;
       
        Entities.ForEach(( ref Translation translation ,ref MovementComponent movementComponent, ref PhysicsVelocity physicsVelocity, in TimeComponent timeComponent) =>
        {
            RaycastInput raycastInput = new RaycastInput
            {
                Start = translation.Value,
                End = translation.Value - new float3(0, -1, 0)
            };
       
            bool isGrounded = IsGrounded(raycastInput);
           
            if (isInputAvaliable && isGrounded)
            {
                movementComponent.lastDirection = direction;
                physicsVelocity.Linear = new float3(xValue, 0, zValue) * timeComponent.localTimeScale * movementComponent.groundSpeed;
            }
        }).Run();
    }

    public bool IsGrounded(RaycastInput raycastInput)
    {
        Unity.Physics.RaycastHit raycastHit = new Unity.Physics.RaycastHit();

        if (collisionWorld.CastRay(raycastInput, out raycastHit))
        {
            return true;
        }
        return false;
    }

this code isn’t working because of Isgrounded function. How should I do that ?

I’m pretty sure you have to fetch the collision world every update. See if moving collisionWorld = buildPhysicsWorld.PhysicsWorld.CollisionWorld; to OnUpdate fixes the problem.

It’s say Assets_Scripts\System\MovementSystem.cs(27,9): error DC0004: Entities.ForEach Lambda expression captures a non-value type ‘this’. This is only allowed with .WithoutBurst() and .Run()

Make your IsGrounded method static