Blood Engine
Blood Engine is a module that can emit blood drips from a base part and make them fall and form pools on the ground. The system uses some predefined constants, variables, and functions to control the behavior and appearance of the blood drips. You can customize the settings of the system, such as the limit, the speed, the delay, the offset, and the visibility of the droplets. You can also use different methods to emit droplets from different parts, directions, and amounts.
It also is possible to use this module for other uses. Just tweak some settings and Tada:
You can also use decals instead by changing the Decals
boolean to true
! Here’s how it looks:
Usage
To use Blood Engine, you need to require the module in your script and create a new instance of it. You can pass some arguments to the constructor to change the default settings of the system. For example:
-- You can leave any of these values as nil or not assign them, it'll use the default values
local DripSettings = {
Decals = false, -- Use if you want to have your pools be decals instead of cylinders.
RandomOffset = true, -- Whether to randomly offset the starting position of the droplets or not.
DripVisible = false, -- Whether to show the droplets before they become a pool or not.
DripDelay = 0.01, -- The delay between each droplet.
DecayDelay = {10, 15}, -- Each pool will start to fade away randomly between min and max seconds after it’s created.
Speed = 0.5, -- Determines the speed/velocity of the droplets.
Limit = 500, -- The maximum number of droplets/pools.
Distance = 1, -- The required distance for the droplet to register with the part below it.
PoolExpansion = false, -- Whether to expand the pool or not when a droplet lands on it.
MaximumSize = 0.7, -- The maximum X size of the droplets.
DefaultSize = {0.4, 0.7}, -- Minimum and Maximum. Both determine the default size of a pool.
ExpansionSize = {0.1, 0.5}, -- Minimum and Maximum. Both determine the expansion size range of the pools.
Filter = {} -- An array that stores instances that don't interfere with the droplets raycast process.
}
-- MODULE
local BloodEngine = require(ReplicatedStorage.BloodEngine)
local BloodInstance = BloodEngine.new(DripSettings) -- customize to whatever you want
Then, you can use the Emit
method to create blood drips from a base part in a given direction with a given amount. For example:
-- TARGET
local Part = workspace.Part
-- Emits drips from a part in the workspace, emits 10 blood drips only in the front direction
-- Leave the direction nil if you want it to go in a random direction `BloodInstance:Emit(Part, nil, 10)`
-- EXAMPLE: BloodInstance:Emit(Part, nil, 10)
BloodInstance:Emit(Part, Part.CFrame.LookVector, 10) -- also customize to whatever you want.
You can also change the settings of the system after creating an instance by accessing its properties. For example:
BloodInstance.Settings.Speed = 0
BloodInstance.Settings.DripDelay = 5
Now if you’d want to make a fully-fledged system that makes blood appear in all clients, you can make a remote event, from server to client. When drips are needed, you can pass off the settings (BasePart, Direction, Amount) and the client will do the rest. It’s recommended to have only one script manage the blood engine and let the server use its Emit method using the remote event.
Why use it?
Blood Engine is a simple and efficient way to add some gore and realism to your games. It can be used for various purposes, such as fps games, melee combat games, horror games or any game that involves blood. It can also be used for other effects besides blood, such as maybe water, paint, slime, etc. You just need to change the color and texture of the drip part.
Change Log
#V.0.0.1
General:
- Release
#V0.0.2
General:
- Bouncing is now removed due to its instability.
- You can now make drips go in random directions more efficiently.
- Added the ability to make blood drips ignore certain descendants of parts efficiently.
#V0.0.3
General:
- Revamped how settings work/get applied.
- Added an option to make pools expandable if collided by droplets.
- Added the option to change the default size of a pool.
#V0.0.4
General:
- Improved drip raycast accuracy.
- Added
DecayDelay
, manages the decay time for each pool.- Pools can now get on walls and attach/get welded to parts.
- Support for decals/images for pools. Includes PBR Materials.
Download
*The GitHub repository provides an additional ‘sounds’ folder for your convenience in case you require SFX for the system.