Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Pendrokar · Jul 15, 2014 at 08:57 PM · performanceparticlesgravityshurikenlegacy

How to create a ParticleSystem whose particles orbit it independently?

Sure such a system can be created by having a empty GameObject, which has multiple GameObjects attached to it, each having its own ParticleSystem while also rotating their parent GameObjects. But having such a system with a 100 GameObjects as children has a noticeable impact on performance.

And I am starting to think the Shuriken particle system would be unable to do this.

Comment
Add comment · Show 5
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 drudiverse · Jul 16, 2014 at 11:34 AM 0
Share

it's not easy, there is a spiral/ galaxy particles generator somehwere on the net, i read it and found that shuriken was rather complicated.

avatar image robertbu · Jul 16, 2014 at 01:55 PM 0
Share

You could certainly do it with a single particle system and some code. You would need to get and set properties on individual particles in the particles array.

http://docs.unity3d.com/ScriptReference/ParticleSystem.Particle.html

avatar image davidsirmons · Sep 22, 2014 at 01:31 AM 0
Share

In other words shur-i-can't isn't able to spawn particles at a radius and impart a angular force? Seems like a small requirement.

avatar image incorrect · Sep 22, 2014 at 06:20 AM 0
Share

What do you mean by saying 'orbit independently'? If you want to rotate all particles around some point just rotate particle system and set it's simulation space to local.

avatar image Pendrokar · Sep 22, 2014 at 06:32 AM 0
Share

@davidsirmons, shouldn't the angular force be relative to particle distance from the center of the particle system? If yes then robertbu's suggestion is the only way to do it, via scripting movement of each Particle.

@incorrect, as a placeholder, I am currently rotating the whole particle system. But I would like for each particle to be rotating around the particle system's center independently. "simulation space" is not the issue.

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by Julian_Nementic · Oct 16, 2016 at 04:23 PM

This is old, but for guys who came along to find an anwer. I wrote a small script you just need to attach to the Particle System and than all Particles orbit around its center or to a position given by a transform in the inspector. Keep in mind that the ParticleSimulationSpace has a huge inpact of the Behavior.

 using UnityEngine;
 using System.Collections;
 
 [RequireComponent(typeof(ParticleSystem))]
 public class ParticlesOrbit : MonoBehaviour {
 
     ParticleSystem m_System;
     ParticleSystem.Particle[] m_Particles;
 
     [Header("Keep in mind that this script works only in Playmode")]
     [Tooltip("Make sure to set Particle Simulation Space to world. Otherwise it uses only the center of the Particle System to Orbit.")]
     [SerializeField]
     Transform CenterOfGravity;
 
     public float strength = 1.0f;
 
     void Start()
     {
         InitializeIfNeeded();
         if (CenterOfGravity == null)
             CenterOfGravity = transform;
 
         if (m_System.simulationSpace == ParticleSystemSimulationSpace.Local && CenterOfGravity != null)
         {
             Debug.LogWarning("You can only use the Center of gravity variable if the ParticleSystemSimulationSpace is set to World. Now its using the center of the ParticleSystem.", this);
         }
     }
 
     private void LateUpdate()
     {
 
         // GetParticles is allocation free because we reuse the m_Particles buffer between updates
         int numParticlesAlive = m_System.GetParticles(m_Particles);
 
         // Change only the particles that are alive
         for (int i = 0; i < numParticlesAlive; i++)
         {
             Vector3 gravitation = new Vector3(0, 0, 0);
             if (m_System.simulationSpace == ParticleSystemSimulationSpace.World)
             {
                 gravitation = CenterOfGravity.position - m_Particles[i].position;
             }
             else
             {
                 gravitation = Vector3.zero - m_Particles[i].position;
             }
 
             Vector3 normalizedGravitation =  Vector3.Normalize(gravitation);
             m_Particles[i].velocity += normalizedGravitation * strength;
         }
 
         // Apply the particle changes to the particle system
         m_System.SetParticles(m_Particles, numParticlesAlive);
     }
 
     void InitializeIfNeeded()
     {
         if (m_System == null)
             m_System = GetComponent<ParticleSystem>();
 
         if (m_Particles == null || m_Particles.Length < m_System.maxParticles)
             m_Particles = new ParticleSystem.Particle[m_System.maxParticles];
     }
 }
 

Cheers,

Julian

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 sybrid · Feb 23, 2017 at 09:07 PM 0
Share

@joellehoelle - Thanks a bunch! This script was very helpful!

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

28 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 avatar image avatar image avatar image avatar image

Related Questions

How to generate particles from an animated character? 0 Answers

Grass system? 2 Answers

Multiple particle systems or UV animation? (performance) 2 Answers

Prewarm Legacy Particles 0 Answers

Is shuriken well performing on iDevices? (iPhone, iPad) 1 Answer


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