Find part incepting particle emitters

ROBLOX - Find part incepting the fall of a particle emitter.


The Goal:

  • Between the Spawn Block (1st image, far right) to the big grey wall (1st image, far left) there is 85 studs.
  • I would like any part within these 85 studs from the Spawn Block with the name partName that IS IN THE PARTICLE EMITTER to be logged in the console.
  • It doesn’t matter whether the part takes up the whole part emitter or just a bit of it.

image

My Progress:

  • None. I’ve had and tried several different ideas listed below.
  • I have thought about ray casting and got the basics set up, however it’s in a straight line and not following the curve of the particles - I’ve looked at a few Dev Forum posts about potential the equivalent of the “bullet drop”, but nothing has came up.

My Ideas:

  • Initially I thought about just a simple onTouched event, yet that doesn’t work with particle emitters so I’m just discarding that idea.
  • I then thought about the “missle” idea with parts, but read a similar Dev Forum post here that is near to what I wish, however it said that the missle of spreading parts isn’t really effective, and I’d agree.
    • Using this post, I then went and learnt about ray casting and did a basic test with that but it can’t really work with the length of my particles and the acceleration drop, no line from the Spawn Block will hit everywhere in the stream of 85 studs.

What Would Be Appreciated:

  • Being pointed in the correct direction (ie. giving another technique that is both effective and possible).
  • Being assisted with a simple ray cast script that can take note of the acceleration drop (listed below) - this would be amazing if anyone could assist.

These particle emitters however would be moving (attached to a player) in which the rays would need to fire out at constant intervals, this shouldn’t be a performance issue I hope (as only 1 would be in the game at a time) but any notes about this would be appreciated too.

Key Notes:

  • The particle emitter’s acceleration is [0, -15, 0].

Hmm, fascinating that I had the same idea concluded in that post. Afterall, it seems like that’s the best way to go about the problem. Personally, I would use that method and create a part behind the wall. I don’t how you would incorporate ray casting in correlation to acceleration, I’ve tried it before and it doesn’t seem to work. You mention you have tried the method and it isn’t accurate:

Can you perhaps provide how you benchmarked this?

Summary
local runservice = game:GetService("RunService")
local part1 = Path_To_EmitterPart -- > particle emitter part
local part2 = Path_To_SecondPart -- > part behind wall
local particle = Path_To_ParticleEmitter -- > particle emitter

runservice.Heartbeat:Connect(function()
	local rayOrigin = part1.CFrame.Position 
	local direction = (part2.Position - part1.Position) 
	
	local raycastParams = RaycastParams.new()
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	raycastParams.FilterDescendantsInstances = {part1, part2}
	
	local raycastResult = workspace:Raycast(rayOrigin, direction, raycastParams)
	if raycastResult then
		print(raycastResult.Instance)
	end
end)

Basically I just got a block and logged when the raycast hit something before it went over the stud limit - it works in a straight line but as soon as the particles started to bend down, the ray cast just didn’t log that anything was in the particles, and such I concluded that the raycast only went in a straight line, and didn’t bend down.

Which idea did you believe that I concluded upon - I suggested several, some deemed impossible (such as onTouched with the particle emitter) and some that are plausible like the “missile” parts or raycasting.

The end goal is to have a part in the world that needs to be touched by the particles from the particle emitters, I can easily sort that bit out but just need to think how to detect it - and still thinking raycasting would be the best idea.

I basically just need to find out how to have a raycast that follows this red line - ideally not skipping to the end as it wouldn’t detect parts in the middle due to the curved shape:

One thought I had was to fire many raycast lines to set intervals (around 5 studs) but I wouldn’t want it to decrease performance.

So, me being a complete egghead forgot that raycast doesn’t support curves, so Idea 2 (missile idea) has just go thrown out the window - the one that I suggested would be best to go about.

I reckon you would need to raycast along the curve of the particles proportionately. The tricky part is how you’re going to find a equal position of proportion along the curve. Your points would need to form a perfect triangle, allowing us to have the radius. Essentially, you’re diagram would look something like:

....PNG

This looks something like 1/4 of a circle. How to find the arc position is my question (not arc length). This would work solely on a perfect triangle, so once any side becomes longer, you no longer have a radius. This is rather hacky method, and probably shouldn’t be used.


My other suggestion is to have a few transparent parts along your particles forming a chain along the curve, and raycast between each part. This is more a technical way to go about it, and should work for your use-case. Make sure to blacklist your transparent parts.

Edit: So I was thinking about this and I reckon a better method is by raycasting downwards, perhaps each stud from a part that is size of your particle emitter. Lets suppose that you have smaller parts within your curve. You would raycast each stud or so, downwards from your larger part to your transparent parts. Then find whatever is intersecting those smaller parts. See below (Apologise for absolute :potato: drawing)

.....PNG