Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by DanielRS · Feb 27, 2014 at 08:42 PM · 2dparticlesemitter

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by jofa · Aug 21, 2018 at 02:49 PM

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 :)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image doghell · Jul 06, 2019 at 07:37 PM 0
Share

This worked.

avatar image
1

Answer by giano574 · Feb 27, 2014 at 09:06 PM

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DanielRS · Feb 27, 2014 at 09:09 PM 0
Share

Yeah, I've been searching about generating particles only in the x-y plane and found nothing. Currently I'm trying to do it through a script. I'll update the post if I get it working.

avatar image giano574 · Feb 27, 2014 at 09:12 PM 0
Share

Yes, I fear that is the only solution.

avatar image
0

Answer by eits · Feb 23, 2017 at 02:06 PM

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:

https://docs.unity3d.com/ScriptReference/ParticleSystemSimulationSpace.html

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Assets/Scripts/PlayerController.cs(32,49): error CS0126: An object of a type convertible to `float' is required for the return statement 1 Answer

Matching collision normal for sub-emitter 0 Answers

No particle emitter in hieararchy, but particles still appearing?? 2 Answers

Flat 2d image on 3d character. 0 Answers

[2D] Getting particles to collide with a game object(Explosion debris effect) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges