Snow in a snow globe?

Was looking to use a particle effect inside an inverted sphere to keep the snow, in the globe. It doesn’t seem like particle collision is supported. Is that correct? Any thoughts on how to achieve such a thing?

Original Post on Discord

by user 236905740416057345

Hello there – we have an experimental AI bot :robot: that might be able to help you with your question. Would you like to try this out?

How it works:
Reply to the messages of the bot that end with a thread_id to interact with it and ask follow-up questions. You can also mention the bot directly in this channel to get help.

Help requested: please wait a moment…

Here is what I found for you :brain: Discord

You are correct, Snax, the Needle Engine does not provide a built-in particle collision system. However, an approach to keep particles within an inverted sphere could be to manually control the particle positions. One idea is to check the particles’ positions each frame and if they move outside the sphere, reposition them back inside.

To manually update particles, you would use the update method on a particle system. When updating particle positions, if a particle’s position is outside of your inverted sphere, you would set it back to a new position inside the sphere. This can create the effect of particles bouncing inside or being contained within the sphere’s boundaries.

Here is a pseudocode example of what that might look like:

  1. Create a custom update function
  2. On each frame, loop through all active particles
  3. Check if a particle’s position is outside the inverted sphere
  4. If it is, reposition it to a valid position inside the sphere
import { Behaviour, ParticleSystem } from "@needle-tools/engine";

export class SnowGlobeEffect extends Behaviour {
  private particleSystem: ParticleSystem;
  private globeRadius: number;

  start() {
      this.particleSystem = this.gameObject.getComponent(ParticleSystem);
      this.globeRadius = /* set the sphere's radius */;

  update() {
      this.particleSystem.update((particle) => {
          if (this.isOutsideGlobe(particle.position)) {
              particle.position = this.getNewPositionInsideGlobe();

  private isOutsideGlobe(position: Vector3): boolean {
      // Implement logic to determine if position is outside the inverted sphere

  private getNewPositionInsideGlobe(): Vector3 {
      // Implement logic to calculate a new random position inside the sphere


Adjust the isOutsideGlobe and getNewPositionInsideGlobe methods to match the logic you need for keeping particles within the globe. Keep in mind that this approach can be performance-intensive, depending on the number of particles and the complexity of the calculations. (see the documentation)

1 messages left GPT 4

Hi, yes particles collision is not implemented right now but you can access the underlying quarks particle system and add a behaviour to archieve something as the bot suggested to get a callback for each particle)


I would suggest you take a look at the source code and awake() of our particleSystem component (blue link in unity on the particlesystem component to open it)

Often this effect is achieved by either

  • adjusting the particle system properties so that the particles don’t fly out (e.g. with rotational forces or lifetime)
  • or particles that do fly out are simply made transparent (e.g. with the callback Marcel mentioned above).

Both are computationally much cheaper than actually doing something with collisions.

The next version will expose the underlying quarks ParticleSystem engine and adds a method addBehaviour to the component so you can easily add or remove custom behaviours


class MyParticlesBehaviour extends ParticleSystemBaseBehaviour {
    update(particle: QParticle): void {
        particle.position.y += 5 * this.context.time.deltaTime;
export class Test extends Behaviour {
    start() {
        this.gameObject.getComponent(ParticleSystem)!.addBehaviour(new MyParticlesBehaviour())

Available in 3.27.3 beta Discord

Awesome, looking forward to it!

by user 236905740416057345

Let me know when you have tried (it is available in the latest versions)

@Snax hi, did you had a chance to try?