Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 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 benhumphreys · Jun 23, 2014 at 05:54 AM · randomparticlesystemshuriken

ParticleSystem.randomSeed doesn't work?

I'm trying to set the seed of a particle system so every time it's run, the particles move in the same pattern.

I've attached what I'm using below. What am I doing wrong?

 using UnityEngine;
 using System.Collections;
 
 public class ParticleRandomTester : MonoBehaviour {
 
     uint m_seed = 42;
 
     ParticleSystem m_ps;
 
     [SerializeField]
     bool m_restart;
 
     void Awake()
     {
         m_ps = gameObject.GetComponent<ParticleSystem>();
     }
 
     void Update()
     {
         if (m_restart)
         {
             m_restart = false;
             Restart();
         }
     }
 
     void Restart()
     {
         m_ps.Clear();
         m_ps.Stop();
         m_ps.randomSeed = m_seed;
         Debug.Log("Setting seed: " + m_seed);
         m_ps.time = 0;
         m_ps.Play();
     }
 }
Comment
Add comment · Show 1
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 benhumphreys · Jul 08, 2014 at 09:41 AM 0
Share

I've simplified this even further and still it runs differently every time.

 using UnityEngine;
 using System.Collections;
 
 public class ParticleRandomTester : $$anonymous$$onoBehaviour
 {
     void Awake()
     {
         var ps = gameObject.GetComponent<ParticleSystem>();
         ps.randomSeed = 42;
     }
 }

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by benhumphreys · Jul 08, 2014 at 09:57 AM

Nevermind I found the answer. You have to use Simulate to actually reset the ParticleSystem and get it to use the new randomSeed value. Stop and Clear don't help.

 ps.randomSeed = 42;
 ps.Clear();
 ps.Stop();
 ps.randomSeed = 42;
 ps.Play(); // Nope
 
 
 // Yup
 ps.Simulate(0, true, true);
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 the_othernet · Jul 16, 2016 at 10:08 AM 0
Share

Thanks for this. I was seeing the same behavior in 5.4.0f1

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

22 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

Related Questions

How to control particle lifetime when emitting programmatically? 1 Answer

ParticleSystem GetParticles returns 0 0 Answers

Unity particle collision detection 0 Answers

ParticleSystem position bug on mobile devices? 4 Answers

Turn on Shuriken "Simulate" from script in Edit mode? 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