Particle Collisions - prevent particles from going through walls! And easily create particle collisions!

Yeah… didn’t notice that. I’ll try to get a fix to acceleration soon. I just need to know how roblox calculates it.

1 Like

Im guessing you do some checks if their is acceleration and modify the direction with the acceleration, you can spilt the raycast into multiple raycast to perform a check by continuously following the acceleration until the max distance.

1 Like

Thank you, i’ll look into this further. I’ll let you know if i find a way to add acceleration support.

This module is pretty cool, though most likely Roblox will add particle collisions, since they’ve been doing some improvements to the particle system, and other systems recently.


To be honest, the source code looks pretty bad. The formatting is weird, there are massive gaps of just whitespace, and some places need newlines to make the code look more readable. For personal projects, readable and good looking code is not important, but for open source community resources, having presentable code can make it easier for other people modify it, although good looking code is purely subjective, some changes have to be made.

I’ve made a few changes to the source code to better align with how my code looks, which is just my opinion, write code however you want, just make it readable to everyone.

--// BIack1st

local ParticleColl = {  }
local Blacklisted = {  }

local PhysicsS = game:GetService("PhysicsService")


function ParticleColl.new(starterPart: Part, particles: ParticleEmitter)
	local function checkGroups(group1: string, group2: string)
		return PhysicsS:CollisionGroupsAreCollidable(group1, group2)
	end
	
	local groupId = starterPart.CollisionGroupId
	local groupName = PhysicsS:GetCollisionGroupName(groupId)
	
	local function getDir(part: BasePart, particles: ParticleEmitter)
		local ParticleDirection = particles.EmissionDirection
		
		if ParticleDirection == Enum.NormalId.Top then
			return part.CFrame.UpVector
		elseif ParticleDirection == Enum.NormalId.Back then
			return -part.CFrame.LookVector
		elseif ParticleDirection == Enum.NormalId.Front then
			return part.CFrame.LookVector
		elseif ParticleDirection == Enum.NormalId.Bottom then
			return -part.CFrame.UpVector
		elseif ParticleDirection == Enum.NormalId.Left then
			return -part.CFrame.RightVector
		elseif ParticleDirection == Enum.NormalId.Right then
			return part.CFrame.RightVector
		end
	end

	local dir = getDir(starterPart, particles)
	local result = workspace:Raycast(starterPart.Position, dir * 5000)

	if result then
		local rayInst = result.Instance

		local pos = result.Position

		particles.Lifetime = NumberRange.new((starterPart.Position - pos).Magnitude * (5.3 / particles.Speed.Max / 2) / 2.75)
	else
		particles.Lifetime = NumberRange.new(math.huge)
	end
end

return ParticleColl

My version was made for fun, you don’t need to use it.

Here are a few things with your code that should be improved:

  1. Big gaps of whitespace, e.g. 49 - 56.
  2. Parts of the code is super clustered together, with nearly no whitespace added to make it look nicer, e.g. 1 - 13
  3. The array with all the methods is named “module”, not something that tells the reader what it is.
  4. (Subjective-ish) Capitalized variable / parameter names. Most programmers (including myself) use capitalized names for important data, like constants, module arrays, etc. etc.
1 Like

Thank you. I’ll take this into consideration next time im coding something.

1 Like

Once Roblox finishes the particle emitter shapes system, do you think it’ll still work with your current module?

More about the new particle emitter shapes: New Procedural Particle Emitter Shapes


I only optimize and make my code readable when I’m either done with it, or when I make something open source. It doesn’t matter how good your code looks if you’re the only person looking at it.

1 Like

I really like the particle shapes. I do plan on adding it. I just need to find out the right formula to make it have collisions.

1 Like

post has been deleted by author


Version 1.2, Support for cancollide and collision groups!
New version, woo hoo! In this version we’re introducing support for collision groups! This is on by default. From now on, particles will go through baseparts that have cancollide set to false and parts that have collision groups that can collide. Without further ado, lets get right into it!
image
This in action. Red parts can go through green and red parts. But can’t go through blue. As you can also see. The half transparent part has cancollide set to false.

Collision Groups
Now, this one doesn’t really require any scripting at all. All you need to use is the default studio tool, collision groups editor. You can access this by going to model → collision groups editor.

After you press that something on the screen should pop up.

Next, make a new collision group. You can do this by looking at the bottom and double click on +add group.
image

After you click on it, you should be able to type it. You can name it whatever you want.

Once you made the group, your screen should look something like this. The screen may look complicated, but trust me it’s simple:
image
The checkmarks mean weather or not these groups can collide. So when theres a checkmark, it means that the group can collide with the other group. So here in my editor, my group can’t collide with the default group. But can collide with itself. If you want it to be able to collide/not collide with a group then edit the checkmark.

Next, we need to add our part to the group. To do this, select the desired part(more preferably the one with the particles, or the parts in its way).

After you selected the part click on the plus icon by the desired group.

image

Thats it, now your parts can collide/not collide!

Keep in mind, the collision groups dont work for attachments. attachments can only go through parts that have cancollide off.

image
And that’s it for this update! Hope this could help anyone who uses collision groups. This update was meant to make it more realistic with roblox’s collisions. So I hope this helped you! If you find any bugs, have a suggestion, or have feedback then feel free to say below! I’m open to any criticism!

7 Likes

Bro, i swear to god, the community makes awesome stuff for every single tool in studio, why can’t roblox add them? Its kinda weird to see how much devs work for roblox and can’t really make particle collisions or custom motion. I’m not mad, neither try to insult the devs, not even disrespect, but its just the point of view im kinda having right now. I know devs are busy as well fixing bugs, making new content for the catalog and patching exploits/bypasses/illegal scripts but idk man

i believe that roblox is adding particle collisions though

bro this module is soooo helpful

thank you so much for it. Can’t wait for future updates!!

The video doesnt work anymore.

1 Like

i haven’t read the source code, but i cant think of a single reason why dynamic parts would require you to make a new module class instance every time

if you support this functionality internally then you should change this to be more transparent (classes dont magically remember if you’ve constructed them with some arguments before- don’t give this illusion!)

if you dont support this functionality internally, then this is a heaping ginormous memory leak that needs to be addressed ASAP

optimal solution is :GetPropertyChangedSignal and only recalculating when necessary

you are an absolute legend you are so cool

Surprisingly good for games that have something like blood particles and the particles would collide. This is useful, thanks.

finally this exists. i’ve looked for this for years. this is a lifesaver.

the topic bumped itself :rofl:

also good thing is that I can now create better particles for my games

Hi, this module doesn’t work. Do you plan to do anymore updates for it or fixes?

You can use the other one here :wink:

1 Like