Blood Engine - A droplet emitter system

I second this, some sort of Data parameter in Settings > UpdateSettings is causing errors

The error originates from here:

function Settings:UpdateSettings(Data: {})
	-- Variable definitions
	local Filter = self.Filter
	local Params = self.RaycastParams

	for Setting, Value in Data do
		self[Setting] = Value
	end

	-- Update Param properties
	Params.FilterDescendantsInstances = Filter
end

Update, I have taken it upon myself to fix the problem and have succeeded with a bit of work, here are the steps to fix the nil Data problem:

Inside of the UpdateSettings function in the Settings module, replace Settings:UpdateSettings with:

function Settings:UpdateSettings(Data: {})
	-- Variable definitions
	local Filter = self.Filter
	local Params = self.RaycastParams

	if Data then
		for Setting, Value in Data do
			self[Setting] = Value
		end
	end

	-- Update Param properties
	Params.FilterDescendantsInstances = Filter
end

Inside of the Operator module, replace the local Clone = table.clone(self.Handler) section with:

local Clone = table.clone(self.Handler)
Clone:UpdateSettings(Data or {})
Data = Clone

Inside of the Settings module, replace the Settings.new section with:

local self = setmetatable({
	-- Replace with whatever you have here in the original Settings.new module
}, Settings)

-- Make sure the Data table actually is a table and not nil
Data = Data or {}

for Setting, Value in Data do
	if Setting == "Tweens" then
		for Tween, Info in Value do
			self.Tweens[Tween] = Info
		end
		continue
	end
	self[Setting] = Value
end

return self, self:CreateParams()

Xefpq, I did your job for you lol :smile:

1 Like

That is great!

Can you provide a .rbxl of it working?

Thanks!

I should have further tested this version, sorry for any inconveniences chat.
I’ll be uploading a new bugfix version in a tinyyyyy bit.

It’s actually just this specific line change that was needed.

Clone:UpdateSettings(Data or {})

Blood Engine • v1.1.1

↳ General Changes

Fixes: Fixed an issue where if no Data/Settings table was provided, the module would error. This is in reference to this issue: Blood Engine - A droplet emitter system - #224 by Necro_las

Does this need to be destroyed if a new engine is created everytime the client respawns, or will it garbage collect itself? I don’t see a destroy method anywhere for this.

Oopsies I didn’t think anyone would put it in StarterCharacterScripts. I’ll add a destroy method right away.

Blood Engine • V1.1.2

↳ General Changes

A new Destroy method: Added a Destroy method, that I admit should have been there in the beginning. This is for developers who especially use StarterCharacterScripts. (Reference to issue: Blood Engine - A droplet emitter system - #233 by Lukeskyroblox1)

3 Likes

This gives me an error. I’m trying to use it in my NPC.

local bloodEngine = require(game.ReplicatedStorage:WaitForChild("BloodEngine"))
local Humanoid = script.Parent:WaitForChild("Humanoid")
local OldHealth = Humanoid.Health
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

local Engine = bloodEngine.new({
	Limit = 60, -- Sets the maximum number of droplets that can be created.
	Type = "Decal", -- Defines the droplet type. It can be either "Default" (Sphere) or "Decal",
	RandomOffset = false, -- Determines whether a droplet should spawn at a random offset from a given position.
	OffsetRange = {-20, 10}, -- Specifies the offset range for the position vectors.
	DropletVelocity = {1, 2}, -- Controls the velocity of the emitted droplet.
	DropletDelay = {0.05, 0.1}, -- Sets the delay between emitting droplets in a loop (for the EmitAmount method).
	StartingSize = Vector3.new(0.01, 0.7, 0.01), -- Sets the initial size of the droplets upon landing.
	Expansion = false, -- Determines whether a pool can expand when a droplet lands on it.
	MaximumSize = 1, -- Sets the maximum size a pool can reach.
})

Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	local Instances = Engine.RaycastParams.FilterDescendantsInstances
	Engine.RaycastParams.FilterDescendantsInstances = {Instances and unpack(Instances), char}
	
	if Humanoid.Health < OldHealth then
		Engine:EmitAmount(script.Parent:FindFirstChild("Torso"), nil, 10)
	end

	OldHealth = Humanoid.Health
end)
Workspace.Respawning Dummy.Blood:20: attempt to index nil with 'FilterDescendantsInstances'

You can’t access the internal params, just the filter. Try using this:

Humanoid.HealthChanged:Connect(function()
	Engine:UpdateSettings({
		Filter = {Humanoid.Parent}
	})
	
	if Humanoid.Health < OldHealth then
		Engine:EmitAmount(Humanoid.RootPart, nil, 10)
	end

	OldHealth = Humanoid.Health
end)
2 Likes

guys, is there’s a way to make it not collide to a specific player?

nice blood system, but for some reason sometimes the blood doesn’t become flat as it should.
how i can fix that issue?
Снимок экрана 2024-09-26 184920

1 Like

This is interesting almost makes me want to release mine


image

The general tech I made for this is to make puddles that combine together if they land in the same position using a hash-grid method.

2 Likes

Check the newest version [1.1.3] out, it introduces the YSize options which should help your case.

thank you so much! but either I’m stupid or I forgot to do something, but I don’t see any difference after I made splats too flat


If you want the pools to always be flat, set the range to { 0.001, 0.001 }, or { 0.001, 0.005 } if you want some randomness.

1 Like

it’s worked! thanks for this best bloody module!


(If you need any ideas, here they are: make the spots disappear automatically after a certain time when the blood-creator script is destroyed, or without this function, the blood will remain FOREVER on the map and will not disappear) - I don’t know English well and may have made some mistakes in the text)

1 Like

You can’t just destroy the blood script because that basically pauses any operations going on in the script, basically making the blood stay forever.

Why does the droplets show up as a square not like the meshes shown?

figured it out* for some reason wally installs it without the mesh id.

If anyone needs the droplet mesh ID: rbxassetid://15372969595