Help with Making Blood Stick to Walls

Hello, I’m sorta new to Raycasting. I’ve been working on a Blood System. I’ve got the basics down. But I can’t seem to make it so that the blood detects a wall. It seems to just go right through it, and It doesn’t seem to print that it detected a wall.

Here is the code:

-- (Sorry If the code is messy and hard to understand.)
game:GetService("RunService").Heartbeat:Connect(function()
	local origin = script.Parent
	local params = RaycastParams.new()
	params.FilterDescendantsInstances  = {script.Parent, game.Workspace.BloodPuddles, game.Workspace.BloodFolder, game.Workspace["Ignore"], game.Workspace.coolbloodgenerator}
	
	params.FilterType = Enum.RaycastFilterType.Exclude



	local hitbox = workspace:Raycast(script.Parent.Position,Vector3.new(0,-1,0), params)
	
	if hitbox then
		if hitbox.Instance.Name == "Baseplate" then
			print("hit baseplate")
		end
		if hitbox.Instance.Name == "Wall" then
			print("hit wall")
		end


		local puddle = game.Lighting.Puddle:Clone()

		puddle.Position = hitbox.Position 
		puddle.Parent = game.Workspace.BloodPuddles
		puddle.Expand.Enabled = true
		task.wait(0.4)
		script.Parent:Destroy() 

	end

end)



Warning: Contains Blood

P.S: This is my first post, so please say something if I did something wrong.

2 Likes

Afaik you are raycasting straight downwards rather than to the side

Thank you! I didn’t realize it was that simple of a problem. It seems to go onto the floor and the wall correctly now. Now I just got to make it so it rotates correctly.

This is what I changed the code to if anybody has this kind of issue,

local hitbox = workspace:Raycast(script.Parent.Position,Vector3.new(-1,-1,-1), params)

image

Also, sorry for the late response. I went to sleep right after I made this post.

Actually, I have one more question. How would I make the blood not be able to go through walls if it already hit it? As shown in this screenshot:

If you want to make the blood align with what it hit, do Blood.CFrame = CFrame.new(RaycastResult.Position, RaycastResult.Normal)

I think you misunderstood my question. Sorry if my question was unclear, but I wanted to know if It’s possible to make the blood not go through the wall, but also still hit the wall. To clarify, I want the blood to be stopped by a wall, not go through it. (Turning CanCollide on does this but it causes the blood to be weird, and not work correctly.)

The result I want is shown in the example below:

Note: Everything with my blood system is Clientsided, I don’t know if its impossible with Clientside, but tell me if it is.

Raycasts will automatically detect walls and return the position of the point of intersection as long as the wall’s CanQuery property is turned on. However to get a realistic effect you can rotate the blood effect relative to the normal of the raycast.

puddle.CFrame = CFrame.lookAt(hitbox.Position, hitbox.Position + hitbox.Normal)

Do you mean the trail following the particle of blood?

Yes, basically. But I ended up solving it myself. Thanks for all the help everybody!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.