I’m making a combat game, and I want to make the characters bleed a little bit when they’re hit. I already have the scripts figured out for the hit event and spawning parts.
My problem is that I don’t know whether to use brick parts or particles for the blood. The script I have currently will spawn a random amount of “blood parts” when a character is hit:
local function OnPunchHit(player, touchedHumanoid, punchDamageMin, punchDamageMax)
touchedHumanoid:TakeDamage(math.random(punchDamageMin, punchDamageMax))
for i=math.random(1, 3), 1, -1 do
local bloodPart = Instance.new("Part", workspace)
bloodPart.CFrame = touchedHumanoid.Parent.HumanoidRootPart.CFrame
bloodPart.Rotation = Vector3.new(math.random(-180, 180), math.random(-180, 180), math.random(-180, 180))
bloodPart.BrickColor = BrickColor.Red()
bloodPart.Size = Vector3.new(1, 0.5, 1)
bloodPart.CanCollide = false
local bloodPartVelocity = Instance.new("BodyVelocity", bloodPart)
bloodPartVelocity.Velocity = Vector3.new(math.random(-15, 15), math.random(2, 5), math.random(-15, 15))
game:GetService("Debris"):AddItem(bloodPartVelocity, math.random(-0.5, 0.5))
game:GetService("Debris"):AddItem(bloodPart, 2)
end
end
Is this approach good, or could I get a better looking blood effect using particles?
I think it’s best to use parts, but enlarge them when they hit the ground. You could also apply an impulse to them and add multiple parts rather than just one…
edit: or add spherical puddles in the position where they hit the ground rather than enlarging them
What do you mean by “impulse”? I applied a BodyVelocity to each part if that’s what you mean. Also, I do spawn multiple parts. It is a random number from 1 to 3, and the amount actually spawned is a bit more because of the way I made the hit detection.
Something I believe could be done is add trails to the parts rather than have the parts themselves represent the blood particles.
You could color it red and change the lifetime to 0.5.
I can’t figure out how to make the blood parts change when they hit the ground. Instead, they change when they hit the character they came out of. I tried adding a check to make sure the blood would only become a pool if it didn’t hit a character, but for some reason that doesn’t work. Do you know a way to do this?
(EDIT) This is the code I used:
bloodPart.Touched:Connect(function(hit)
if hit:IsDescendantOf(player.Character) == false and hit:IsDescendantOf(workspace.Dummy) == false then
print(hit.Name.." Was not part of a character")
bloodPart.Rotation = Vector3.new(0, -90, 0)
bloodPart.Anchored = true
bloodPart.Size = Vector3.new(math.random(1.5, 4), 0.25, math.random(1.5, 4))
else
print(hit.Name.." Was part of a character")
end
end)
For my blood system, something I did was place all the parts and models that were part of the map in a folder called “Map”, and then checked if the blood part hit a part that is a descendant of that folder using something like this:
if hit:FindFirstAncestor("Map") then
-- rest of the code to change the blood part
end