[PERMANENTLY ARCHIVED] [v.160] SimpleZone | A simple, fast and new Zone module!

Package Version 155 (SimpleZone) & 180 (LessSimpleZone):

  • Fixed the Query type being nullable and added error checking for when it isn’t a function

my event isn’t firing when parts from a character rig enters. It only fires when players enter :slightly_frowning_face:
Is there a specific setting to change that, or is it a bug with the module?

Can you share your zone detection code?

the script itself is very long so I’ll just give you the parts that matter

local self = setmetatable({}::self, module)
	self.important = {
		owner = owner,
		zone = simpleZone.fromPart(part),
		config = config,
	}

and the connection

self.important.enterConnection = self.important.zone.ItemEntered:Connect(function(object)
		print(object) -- only prints players 💔💔💔
		self.Touched:Fire(object)
		
		local character = IdentifyCharacter(object)
		local onimpact = self.important.config.destroyOnImpact
		local onimpactplayer = self.important.config.destroyOnPlayerImpact
		local onimpactobject = self.important.config.destroyOnObjectImpact

		local isPlayer = false
		local humanoid = nil

		if character then
			humanoid = character:FindFirstChildOfClass("Humanoid")
			self.TouchedChar:Fire() 
			if game.Players:GetPlayerFromCharacter(character) then
				isPlayer = true
			end
		end

		if not character then
			self.TouchedPart:Fire(object)
			if determineDestroy(onimpact, onimpactplayer, onimpactobject, isPlayer) then
				self:Destroy()
			end
			return
		end

		local ownerCharacterModel = nil
		if self.important.owner then
			if self.important.owner:IsA("Player") then
				ownerCharacterModel = self.important.owner.Character
			elseif self.important.owner:IsA("Model") then
				ownerCharacterModel = self.important.owner
			end
		end

		if ownerCharacterModel and character == ownerCharacterModel then
			self.TouchedChar:Fire(character) 
			if determineDestroy(onimpact, onimpactplayer, onimpactobject, isPlayer) then
				self:Destroy()
			end
			return 
		end

		self.TouchedChar:Fire(character)

		if not humanoid or humanoid.Health <= 0 then return end

		humanoid:TakeDamage(self.important.config.impactDamage)

		if self.important.config.dps ~= nil then
			self.hitData[humanoid] = {
				lastHitTime = self.important.config.cooldown or 0, 
				hitsCount = 0, 
			}
		end

		if determineDestroy(onimpact, onimpactplayer, onimpactobject, isPlayer) then
			self:Destroy()
		end
	end)
1 Like

Hi, do you want the body parts to get sent to .ItemEntered too along with the Player? I think I can do that

Yes please :pleading_face::pray:
if possible could you also make it so NPC body parts also get sent in?
Thank you :pleading_face:

1 Like

Package Version 157:

  • Added the ability to do Zone:ListenTo("BodyPart", ...) which checks if the item’s parent contains a Humanoid
  • Changed all dependencies and modules to use --!strict and removed all type errors
  • Updated SimpleSignal to remove the constant task lib error
1 Like

Heyo, I tried using this quite a while ago while it was in it’s early stages as a substitute for ZonePlus however even with your advice (low frequency + query blacklist everything) it performed significantly worse, do you think now months later I’ll have better luck with this?

I say give it a shot :V I’ve implemented alot of optimizations that should be pretty good, especially query spaces which are very very optimal for large zones

Any chances you could make something that dynamically sets character to new if it’s passed with the query space stuff on your end? kinda iffy having to constantly destroy/create the zones due to Player.Character not existing anymore upon refresh - unless there’s another way I’m not familiar with?

1 Like

Just an update on this, I’m using query spaces, ONLY whitelisting the character, the zones have a custom collision group that is only paired with the character and it still performs worse than ZonePlus - my update interval is randomized between 2 - 6 seconds and they’re set to static. Not sure what I’m doing wrong? using fromParts too.

Wdym by performs worse than zoneplus? Is it like the activity or the rate in script performance widget, also yea I can try implementing automatic character refreshment

The script usage is considerably higher and I’m just overall worse frame rate. I do have a very high number of zones, some are very large - side note making everything work outside of workspace is a headache due to the character refreshment stuff so that would be amazing!!

1 Like

Interesting :thinking: Can you send a microprofiler dump/analyze what’s taking up the most frametime? If my guess is correct it’s most likely GetPartBoundsInBox, aside from that though I do think ZonePlus is more performant because:

  1. it uses BasePart.Touched for the zones, which I’ve been reluctant to do because, well, what’s the point of a zone module if I’m just gonna use .Touched anyway :thinking:

  2. It does volume checks when doing queries & special detection methods for datatypes (like local player, player characters) which I actually just realised i can do for SimpleZone :thinking: I’ll implement this in 158

  3. I actually just read through it and I think ZonePlus tracks items manually and only uses spatial queries for checking if they’re in the zone instead of getting all items within the zone, idk if this is the reason why it’s more performant but i think it could be a factor

  4. BVHs aren’t really the most optimal way of creating big zones and i am looking at alternatives which provide better dynamicality and better early culling, which will also be implemented in 158

Other than that, i wouldn’t know until you send some information about what exactly is causing the performance issues :V

Hi, i actually tried some debloating and optimization and what i found is that using LessSimpleZone’s IsBoxWithinZone method for queries, like this:


Was like,,,, really fast, I was reaching 60 fps with 9_000 individual parts in 1 zone, this checking method is only used if the total volume of all tracked items is less than the total zone volume, though I might change that depending on the performance outcomes

I also decided to just completely strip SimpleZone of the BVH and give it to LessSimpleZone instead because it was making the module alot longer and didn’t really provide much benefits (unlike LessSimpleZone which utilizes it to speed up point and box checking functions)

The newest versions are 158 and 184 for simplezone and lesssimplezone, if you have alot of really big zones you should try out LessSimpleZone and see if it fixes your performance issues

For some reason, ListenTo does not show up in autofill?

1 Like

Hi, what version of SimpleZone are you using?

151

char limit is atrocious, dont know why it exists

1 Like

Hi, I dunno if autocomplete works in that version but I’d recommend getting the newest version either by updating your PackageLink or via the marketplace download

Also yea they should remove it :confused:

It shows up to date?
image