Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by Mikoziq · Jun 09, 2017 at 05:27 PM · instantiateparticlesparticlesysteminstantiate prefabspread

Best way to spread particle system?

Hello,

I am currently working on propagation of fire and therefore I am not completely sure, if there are multiple or better ways of making Particle Effect spread instead of Instantiate().

My current way of thinking, is that I have central point of my fire, and it makes new fire instances over time in random way away from the central point. It looks cool, but it is really costly... My PC cannot maintain to run with 20+ Particle Systems cloned, even if I make them less detailed (for example making max of 10 particles/each system).

How can I achieve a optimization for this? Maybe there is another way of spreading this?

Any help would do.

     private void FixedUpdate()
     {
         if(Time.fixedTime % .5 == 0 && Time.fixedTime < 5)
         {
             CloneFire();
         }
     }
 
     void CloneFire ()
     {
         Vector3 newFirePos = new Vector3(newFireX + Random.Range(1f, -1f)*Time.fixedTime*2, 0.2f, newFireZ + Random.Range(1f, -1f) * Time.fixedTime*2);
         fireClone = Instantiate(fireStarter, newFirePos, Quaternion.identity) as GameObject;
     }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by juschu · Feb 01, 2018 at 03:54 AM

I didn't try it, but under "Shape" in the particle system you can select a mesh as the source of your particles.
Create a custom mesh and add it to your particle system. To make the fire spread you add more vertices and triangles to the mesh.
I'm not sure if it's necessary, but I had problems with changing a mesh after it was assigned to a mesh collider. If it looks like the mesh isn't updated in your particle system try to reasign the mesh to the particle system after every change to it.

And your Time.fixedTime % .5 == 0could cause some problems. Time.fixedTime is a float value and comparing float values (float % float is still float) with == is always a bad practice. It's alsways a bad practice because of rounding errors, but in this case Time.fixedTime gives you the time of the current frame. So you're relying on one frame hitting exactly a value like 2.5. But it probably would hit something like 2.465456645 or 2.5643453534. And 2.5 == 2.465456645 is false. It's close but for a computer it's still false. I'm really surprised you did see some fire att all.
If you want to do something every x seconds use this instead: https://docs.unity3d.com/ScriptReference/MonoBehaviour.InvokeRepeating.html And if the function shouldn't be called forever use a counter in the function and when it reached its maximum value (or another condition is true) call this function: https://docs.unity3d.com/ScriptReference/MonoBehaviour.StopCoroutine.html

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Syncing particle system in Photon Unity Networking 1 Answer

Generating a particle effect on top of a GUIElement 1 Answer

How to Instantiate gameObject where a particle dies 2 Answers

How to instantiate particle effect after destroying it 2 Answers

performance question about particles and instantiating 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