Calculating drag to minimize particle clipping for flamethrower

Does anyone know a formula for how to calculate what a ParticleEmitters.Drag property should be to minimize the amount of clipping through walls it does? For example see below:
image

I think that things such as Lifetime, Speed, Size and Acceleration are factors in the formula but I’m not exactly sure, even then I don’t know how to use all of that to figure out a formula.

2 Likes

since .drag is determining in how many seconds it would take for particles to lose half their speed (and it is exponential) i think you could try raycasting to get the distance between the origin and the nearest object that would be blocking the particles and go from there. since .speed is measured in studs a second, you could get the distance and divide it by the speed of the particles to get the time, which you could set the particles’ drag to (divided by /1.5 or /2 since drag is determining when the particles lose half their speed, although it is exponential).

then again i could be doing this totally wrong but that’s how i would do it

5 Likes

Doesn’t account for acceleration, but managed to use your post as a base and figure the rest out.


local function ManipulateDrag(Particle, Distance)
	local LargestSize = 0
	
	local Keypoints = Particle.Size.Keypoints
	for Index = 1, #Keypoints do
		local Size = Keypoints[Index].Value
		if Size > LargestSize then
			LargestSize = Size
		end
	end
	
	local Speed = Particle.Speed.Max
	local Time = math.max(Distance - LargestSize, 0) / Speed
	local N = 1.5/ Time
	
	Particle.Drag = N
end
9 Likes

The only problem I see with my code is that the distance at which the particle will travel is limited by the lifetime and speed of the particle.

Idk if this would cause too much of a performance issue but, could you not use a particle emitter? Just create tiny parts and use the canCollide property? I guess it would depend on performance and whether or not you can replicate the visual effect you’re looking for.

Particles are infinitely cheaper then using a bunch of tiny baseparts, even if you just used attachments. Still cheaper, because you’re not instancing a bunch of tiny objects, an manipulating a bunch of CFrames/vector3s and have to instance even more particle objects on top of that, calculate collisions and your own dampering and all that. At the end it just better to mess with a single ParticleEmitters.Drag property to get what you’re wanting.

1 Like

Your right. I wonder if you need to change the speed(drag) at all though? Distance = speed * time. Keep the speed the same and reduce the particle lifetime to the time it would take to reach that distance. Then your effect wouldn’t slow down or speed up based on distance. Unless that is what your going for.

lifetime = distance / speed
emitter.Lifetime = NumberRange.new(Distance/Speed)

3 Likes

That is a more simplified way of doing it I think…and it gives an effect I’m looking for so I think that’ll work.