Allow particles to spawn in hitbox rather than selection box?

I have a city that’s on top of water. I want the particles to come up out of the water but not out of the concrete. So I thought I could negate the concrete out of the water to see whether particles spawned in hitboxes rather than selection boxes. I was wrong.


Could we have a bool value property to enable particles to spawn depending on the Union/Part’s hitbox rather than selection box?

How performance intensive would it be?

https://i.gyazo.com/513d103d01b21732f930a257fce57a5a.gif

1 Like

Holy crap, my mind explodes just thinking of the computations that would be required if it had to be completely accurate

It can probably be approximated if they do it grid-based like lighting, then they could only spawn particles for the cells that are for the majority occupied by the part(/union).

1 Like

Make the particle spawner 0.2 thickness and put it on top of the concrete. That should fix your problem.

I think you read it wrong?

Ah. I see. You could use wedgeparts I think as a temporary ‘close enough’ solution.

Wedges have the same problem ):

RIP. I suppose you could just build around the problem using squares. Then again I’m sure you’ve already thought of that. I know that you can gather all the particles from a table. Maybe you could use their position to see if their X/Z magnitude is within those cylinders. If they are, remove them?

If you do it with regular parts you will have overlaps which leads to differences in particle density.

I have no idea what you mean with the second part, ParticleEmitter has no method like that and if particles were really exposed that way it would probably mean a huge performance decrease.

1 Like

You don’t have overlaps if you don’t create overlaps. Particle density can be compensated using simple X*Z size math.

If you use only rectangle parts to try and fill in the holes around the cylinders in the OP, it’s impossible not to have overlaps unless you approximate and use a bunch of extra parts.

Also we’re talking about this object right? Documentation - Roblox Creator Hub

I don’t see any methods to get or set an array of particles, so I have no idea what you’re talking about when you say you can remove individual particles.

You’ll just have to use square parts (with emitters) and fill the water with those.
You also probably want to set the EmitRate to something like:

EmitRate = part:GetMass() * 100

That would result in 400 for a 2x2 part (assuming the height is 1).
Since it uses the mass, it would be 800 for a 2x4, so the overal EmitRate looks the same.
(EmitRate of 50 is “faster” in a 2x2 part than a 4x4, as the particles spawn closer to each other)

1 Like

That really doesn’t work well either. I overlapped two rectangle parts (necessary if you want to cover the polygon water surface in the OP), with the exact same sizes and exact same emission rates, and this is what you get:


Notice how the particle density is twice as high in the outlined area.

Yeah, I meant without overlapping.
Might be a bit too tricky.

Could always just have a dozens of small parts that you TP around the whole time and use :Emit() on.

From what I see in the OP images you’re generating pretty scarce particles which to your surprise might actually be solved by simply slapping some squares around.

Well, the distribution of particles over area won’t be as good with just hacks like the comments suggests, rather than improving the behavior of particle spawning.

If it’s performance heavy, I suggest adding a property to ParticleEmitters for defining whether to use the hitbox or selection box.

So yeah, I don’t think it’ll be possible without OP’s suggestion, as the difference is evenly distributed particles rather than constant particles in a small area and more randomly spawned particles over bigger areas of particleemitter parts.