Constraint Particle System to only x&y axis?

The title says it all. I’m working in a 2D game and the particle emitter shape is a Cone, Sphere, Hemisphere etc. There’s a way to shape the emitter to a circle or a quad? So particles are only generated in a 2-Dimensional world.

Update 1

This script sets the z-velocity of each particle to 0, successfully keeping the particles in the x-y plane. The only drawback I see is that this can cause some serious performance problems.

using UnityEngine;
using System.Collections;

public class ExplosionController : MonoBehaviour {

  public ParticleSystem particleSystem;

  void Update()
  {
    ParticleSystem.Particle[] particleArray = new ParticleSystem.Particle[particleSystem.maxParticles];
    int particles = particleSystem.GetParticles(particleArray);
    for (int i = 0; i < particles; i++)
    {
      Vector3 vel = particleArray[i].velocity;
      vel.z = 0;
      particleArray[i].velocity = vel;
    }
    particleSystem.SetParticles(particleArray, particles);
  }
}

Update 2

As I only need to set the particles z-velocity to 0 only one time, because the explosion is a non-looping particle system, it’s easy to disable the loop option from the inspector and trigger the emission from the script itself:

using UnityEngine;
using System.Collections;

public class ExplosionController : MonoBehaviour {

  public ParticleSystem particleSystem;

  void Awake()
  {
    particleSystem = gameObject.GetComponent<ParticleSystem>();
  }

  void Start()
  {
    particleSystem.Emit(particleSystem.maxParticles);
    ParticleSystem.Particle[] particleArray = new ParticleSystem.Particle[particleSystem.maxParticles];
    int particles = particleSystem.GetParticles(particleArray);
    for (int i = 0; i < particles; i++)
    {
      Vector3 vel = particleArray[i].velocity;
      vel.z = 0;
      particleArray[i].velocity = vel;
    }
    particleSystem.SetParticles(particleArray, particles);
    
  }
}

It is also easy to adapt this script to your own needs, creating functions to alter color and whatnot.

Best regards.

In the “renderer” of the particle system you can chose the render mode “horizontal billboard”. If you are talking about only creating the particles in the x-y plane, I don’t know if that is possible. Probably not.

Some solutions: @DanielRS

  • Don’t use XY constrain, because particle effect looks much better with 3D shape. Just move Camera back on Z axe and adjust Far clipping plane to have enough space for particles to render
  • If you really need that, you can set particle.shape.scale.Z to zero (or in new Unity use shape Circle :slight_smile:

I had a similar problem when my game was moving vertically and the character horizontally. I wanted the particlesystem to be affected only by the horizontal movement. For this I noticed there is the option to set custom simulationspace:

I set the custom simulationspace to the transform that is moving vertically and now the particlesystems are not affected by the vertical movement.

If anyone still needs this, what worked for me was to enable the Limit Velocity over Lifetime parameter. In there I can enable the Separate Axes option and limit the desired axis velocity to 0 in World space.

image

I wanted to spawn particles in front and behind my character, so setting the volume scale to 0 on one axis wasn’t an option.