Blood drop raycasting currently broken

  1. The drop should land and form a puddle on what it first touches without bouncing off of the ground or a wall first (not the humanoid or any other player.) example of RVVZ’s blood with functioning raycasting:

  2. The blood drop doesn’t land as it should, it lands after bouncing and it bounces right off walls, floors, or slopes. example of a friend testing my blood with broken raycasting:

  3. I’ve tried a bit to fix the blood but after all the attempts failing, I am resorting to the dev forum.

I’m going to share the raycasting section of the blood module, here it is:

local Debris_Folder = workspace:WaitForChild("Debris")
local name = game.Players.LocalPlayer.Name

local Ignore = {Debris_Folder, workspace:FindFirstChild(name)}

function Cast(Origin, Direction)
	local Rays = Ray.new(Origin, Direction)
	local Hit, RayPosition, Normal = workspace:FindPartOnRayWithIgnoreList(Rays, Ignore, false, true)

	if Hit ~= nil then
		if Hit:FindFirstAncestorWhichIsA("Model"):FindFirstChild("Humanoid") then
			table.insert(Ignore, Hit)
			return Cast(Origin, Direction)
		else
			return Hit, RayPosition, Normal
		end
	end
end

Please reply to this post with your version of the code and i’ll let you know if it worked.

2 Likes

The problem is going to be where you call this function and how you determine direction and what you do with this data. Where do you call this function?

1 Like

This is the part where i call it, now if you are looking for more than just this, i can send a bit more of the code if you’d like.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Resource = ReplicatedStorage.Resources:WaitForChild("HumanBlood")
local Drop = Resource:WaitForChild("Drop"):Clone()
--The part above is located somewhere else in the script, and the part below is used deeper into the script
local Hit, RayPosition, Normal =  Cast(Drop.Position, Drop.CFrame.lookVector*0.5)

(dont know if this reply is helpful)

1 Like

What do you do with the “Hit” variable after this?

1 Like

So this is where i used the Hit variable in the script, this is where the blood pool will form and disappear

if Hit then
					Drop.CanCollide = true
					local Radious = math.random(math.random(1, 2))/1
					local Blood_Ground = Resource:FindFirstChild("Blood"):Clone()
					Blood_Ground.CFrame = (CFrame.new(RayPosition, RayPosition - Normal) * CFrame.Angles(math.rad(90), math.random(-360,360), 0)) * CFrame.new(0, 0/2,0)
					Blood_Ground.CanCollide = false
					Blood_Ground.Parent = workspace.Debris
					Blood_Ground.splat:Play()
					TweenService:Create(Blood_Ground, TweenInfo.new(math.random(3, 4), Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0), {Size = Vector3.new(Radious, 0, Radious)}):Play()
					local transparency = TweenService:Create(Blood_Ground, TweenInfo.new(math.random(3, 3), Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0), {Transparency = 0.016})
					transparency:Play()
					Drop.Transparency = 1
					Drop.Anchored = true
					Drop.CanCollide = false
					delay(5, function()
						local Clean = TweenService:Create(Blood_Ground, TweenInfo.new(math.random(1, 1), Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0), {Transparency = .1})
						Clean:Play()
						Clean.Completed:Wait()
						Blood_Ground:Destroy()
					end)
					break
				end

So this is the part where the blood pool forms

Here is the Whole code for the Hit variable (which is a function)

function Blood:Create(Damage, Limb, Current_Health)
	spawn(function()
		local Force = Vector3.new(0, 0, 0)
		local Set_Position = (Limb.CFrame * CFrame.new(0, 0.4, 0)).p
		local Drop = Resource:WaitForChild("Drop"):Clone()
		Drop.Parent = workspace.Debris
		local X, Y, Z = math.random(30, 90)/15, math.random(100, 200)/15, math.random(30, 90)/15
		local _X, _Z = math.random(-100, -1)/10, math.random(-100, -1)/10
		Force = Vector3.new(math.random(_X, X), Y, math.random(_Z, Z))
		Drop.Velocity = Force * 3
		Drop.CFrame = Limb.Parent.Torso.CFrame-- * CFrame.new(math.random(-0, 0)/20, 0, math.random(-0, 0)/20)
		Drop.CanCollide = true
		spawn(function()
			repeat wait()
				--   Cast(Drop.Position, Vector3.new(10/100, 10/100, 10/100))
				local Hit, RayPosition, Normal =  Cast(Drop.Position, Drop.CFrame.lookVector*0.5)

				if Hit then
					Drop.CanCollide = true
					local Radious = math.random(math.random(1, 2))/1
					local Blood_Ground = Resource:FindFirstChild("Blood"):Clone()
					Blood_Ground.CFrame = (CFrame.new(RayPosition, RayPosition - Normal) * CFrame.Angles(math.rad(90), math.random(-360,360), 0)) * CFrame.new(0, 0/2,0)
					Blood_Ground.CanCollide = false
					Blood_Ground.Parent = workspace.Debris
					Blood_Ground.splat:Play()
					TweenService:Create(Blood_Ground, TweenInfo.new(math.random(3, 4), Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0), {Size = Vector3.new(Radious, 0, Radious)}):Play()
					local transparency = TweenService:Create(Blood_Ground, TweenInfo.new(math.random(3, 3), Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0), {Transparency = 0.016})
					transparency:Play()
					Drop.Transparency = 1
					Drop.Anchored = true
					Drop.CanCollide = false
					delay(5, function()
						local Clean = TweenService:Create(Blood_Ground, TweenInfo.new(math.random(1, 1), Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0), {Transparency = .1})
						Clean:Play()
						Clean.Completed:Wait()
						Blood_Ground:Destroy()
					end)
					break
				end
			until Hit ~= nil or Drop:FindFirstChild("Delete")
			Debris:AddItem(Drop, 3)
		end)
	end)
end

return Blood

(Yet again don’t know if this is helpful since this is the first time posting on the Devforum)

1 Like

Is there a reason you don’t straight up delete Drop? You are allowing it to continue to exist which may be causing the problem.

1 Like

The reason I don’t just delete the drop is due to the fact that the trail will abruptly disappear which doesn’t look to good for the drop.

1 Like

But I will proceed to do so and experiment with it.

1 Like

Why is cancollide set to true at the top there? Removing that might also fix it if you don’t rely on that.

1 Like

its done something but not quite, so I’ve experimented with the drop and made it NoCollide and this seems to be happening:

1 Like

Change the raycast direction to this, I think it will help.
Drop.Velocity.Unit*.5

1 Like

Where exactly would I put this?

1 Like

Sorry, I was on mobile.
local Hit, RayPosition, Normal = Cast(Drop.Position, Drop.CFrame.lookVector*0.5)
Replace that line with
local Hit, RayPosition, Normal = Cast(Drop.Position, Drop.Velocity.Unit*0.5)

1 Like

This works tremendously, thank you very much, as I have been working hard to get to this point.

2 Likes