SimpleZone | A simple, fast and new Zone module!

Update: Added “LocalPlayer” as a valid :ListenTo() datatype!

Example:

local zone = Zone.fromPart(workspace.Example)

zone:BindToHeartbeat()

zone:ListenTo("LocalPlayer", "Entered", function()
	print("The local player has entered the zone!")
end)

I also removed some issues regarding overlapping BVH’s with the .fromBoxes() constructor.

Is this module more performant than zoneplus? What are its drawbacks?

Ive done some comparisons and its like marginally faster for spatial queries I think (less loops and function calls than zoneplus), however the real benefit is the flexibility and simplicity this module has that allows you to optimize it yourself and even modify things to suit your needs.
However, LessSimpleZone is actually faster when it comes to :IsPointWithinZone() and :GetRandomPoint() as it does not use checker parts.

The only drawbacks I can think of is that you don’t really have as much done for you (for example calling :BindToHeartbeat() requires you to provide your own OverlapParams), and you cant really do any global zone operations (like .getTouchingZones with ZonePlus ZoneController), but because the module is flexible I think you can actually just add that yourself easily

I thought Iasked this but maybe I did not, can a zone be a mesh ?

Yes, with the LessSimpleZone module (linked in the post now!) you can do LessSimpleZone.fromBasePartsVertices(...) and use an array of meshes (and/or parts)!

1 Like

I can’t update my module with your new version

Mind sending a screenshot? 30charlimit

Hey, @athar_adv I have a problem with your module.
Basically, I have made a lootbag system and created a zone to touch them in the game with your module.
The problem is when I try touching them nothing happens, really sometimes it does what my code says and sometimes not (most of the times), I tried all, checked my code, added prints to see if it hits the box, but nothing, can you help me?

Here’s the code of the zone setup:

local newZone = Zone.new(PrimaryPart, {TrackItemEnabled = true, FireMode = "OnEnter"})

	newZone:BindToHeartbeat()

	newZone:ListenTo("Player", "Entered", function(player: Player)
		print(player) --It does not print even tho the zone spawns
		LootbagModel:Destroy()
		newZone:Destroy()
		AddLoot(Queue, GuiP, Loot, player)
	end)
1 Like

Hello, can you try using .fromPart() instead of .new()?

Also, can you try adding a print before creating the zone to see if it is being created?

Ok I’ll try, thanks!

characters

Thanks so much for making this, this is so great! The most loved feature are the auto-completes & explanations of the code! ZonePlus didn’t have that. Thanks for making this!

1 Like

How do you detect which box the player has entered using fromboxes?

Ah yeah there’s no way to do that right now, let me add custom Query metadata

So, for now, should I use fromPartParallel instead of fromBox for better performance? I have 90+ zones in the client that handle area themes, and they are static.

Yeah for now just use that, I am currently updating the module to allow for custom metadata for queried items

1 Like

Update:

  • Added custom item metadata support as a return for Zone:Query()
    The type of the item must be of type {item: any, metadata: {[any]: any}} if you wish for your metadata to be passed as the second argument to Zone:ListenTo or Zone.ItemEntered/Exited

    Example usage of metadata in the .fromBoxes() constructor:

    The Zone type has been accordingly updated
    Documentation will be updated soon.

While I was testing this, I found that the script performance of fromPartParallel is higher than zoneplus (all running on the client), and fromboxes is even laggier than fromPartParallel. Why is that? (80+ parts with streaming disabled)
image

You can test it using this file and toggle them in PlayerScripts as needed:
test-1.rbxl (107.2 KB)

Ah yeah, that’s probably because .fromPartParallel() utilizes actors too inefficiently : P Probably will update it in the future to be .fromParts() and use my other module ActorGroup2 instead of 1 Actor per Zone, for now if you wish to use alot of parts I’d recommend using the other module LessSimpleZone which has precise geometry (although no part auto-update position & size yet)

Also, you need to provide your own OverlapParams in Zone:BindToHeartbeat(), unless you did, then I’d very much like to find out why this is the case :eyes:

After giving them all the OverlapParams, Their performance is better:
image

test-1.rbxl (107.4 KB)