Ejemplo n.º 1
0
            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));
            }
Ejemplo n.º 2
0
            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));
            }
Ejemplo n.º 3
0
            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);
            }