private bool Overlapped(float3 position, ref FieldOfView setting, ref NativeList <int> hits) { var radius = setting.Radius; var input = new OverlapAabbInput { Aabb = new Aabb { Max = position + new float3(radius, 0, radius), Min = position - new float3(radius, 0, radius) }, Filter = new CollisionFilter { BelongsTo = Setting.SelfTag.Value, CollidesWith = Setting.TargetTag.Value, } }; return(World.OverlapAabb(input, ref hits)); }
private bool Visible ( ref CollisionWorld world, float3 position, float3 detectedPos, ref FieldOfView setting) { var input = new RaycastInput { Start = position, End = detectedPos, Filter = new CollisionFilter { BelongsTo = setting.SelfTag.Value, CollidesWith = setting.TargetTag.Value } }; return(world.CastRay(input, out var hit)); }
private bool InViewCone(ref LocalToWorld localToWorld, float3 detectedPos, ref FieldOfView setting) { var dir = detectedPos - localToWorld.Position; var angle = Vector3.Angle(localToWorld.Forward, dir); var distance = math.lengthsq(dir); var inAngle = angle < setting.Angle * 0.5; var inDistance = distance < math.lengthsq(setting.Radius); return(inAngle && inDistance); }