Hi all. Please tell me why this code does not work if I add the netcode package, but works fine if netcode package is not installed
entities version 1.0.0-exp.8
using UnityEngine;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics;
public unsafe partial class RaycastDebugSystem : SystemBase
{
public Entity Raycast(CollisionWorld collisionWorld, float3 RayFrom, float3 RayTo)
{
RaycastInput input = new()
{
Start = RayFrom,
End = RayTo,
Filter = new CollisionFilter()
{
BelongsTo = ~0u,
CollidesWith = ~0u,
GroupIndex = 0
}
};
Unity.Physics.RaycastHit hit = new();
bool haveHit = collisionWorld.CastRay(input, out hit);
if (haveHit)
{
return hit.Entity;
}
return Entity.Null;
}
protected override void OnUpdate()
{
var physicsWorldSingleton = GetSingleton<PhysicsWorldSingleton>();
var collisionWorld = physicsWorldSingleton.CollisionWorld;
var screenRay = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Raycast(collisionWorld, screenRay.origin, screenRay.GetPoint(1000)) != Entity.Null)
{
Debug.Log("cast");
}
}
}