Search Unity

particleEmitter.Simulate Woes

Discussion in 'iOS and tvOS' started by chrisw, Apr 25, 2010.

  1. chrisw

    chrisw

    Joined:
    Apr 25, 2010
    Posts:
    3
    Hello everyone!

    I'm having some trouble trying to advance my particle system when it loads so it doesn't need a "warm up" period. Looking at the forum everyone seems to recommend trying particleEmitter.Simulate(). I have a particle system set up and working in my scene, and have attached a javascript file to it with the following, very modest test.

    Code (csharp):
    1. function Start () {
    2.       particleEmitter.Simulate(stepSize);
    3. }
    In return, unity says:
    Assets/scripts/particleJumpStart.js(2,23): BCE0019: 'Simulate' is not a member of 'UnityEngine.ParticleEmitter'.

    I would use the time scale trick some people have written about, but it needs to run for a second when set to 99 so it looks pretty silly until it's ready

    Thank you so much for any assistance you can provide - this is confusing the heck outta me.

    -Chris
     
  2. DrunknPirate

    DrunknPirate

    Joined:
    May 10, 2009
    Posts:
    21
    you need to set up something like this

    Code (csharp):
    1.  
    2. var Emitter : ParticleEmitter;
    3. var time : float = 1.0;
    4.  
    5. function Start () {
    6. Emitter.Simulate(time);
    7. }
    8.  
    and then select which particle emitter you need to simulate.

    I also have some problems getting this to work though, seems like the simulate doesn't work with larger values. unity answer recommended:

    Code (csharp):
    1.  
    2. for (i = 0; i < warmupTime; i++) {
    3.    particleEmitter.Simulate(1.0);
    4. }
    5.  
    6.  
     
  3. DrunknPirate

    DrunknPirate

    Joined:
    May 10, 2009
    Posts:
    21
    just tested it, this works for me:

    Code (csharp):
    1.  
    2. var Emitter : ParticleEmitter;
    3. var time : float ;
    4.  
    5. function Start () {
    6. for (i = 0; i < time; i++) {
    7.    Emitter.Simulate(1.0);
    8. }
    9.  
    10. }
    11.  
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, chrisw's code is correct. Just use particleEmitter.Simulate.

    It's not available in Unity iPhone.

    --Eric
     
  5. DrunknPirate

    DrunknPirate

    Joined:
    May 10, 2009
    Posts:
    21
    fair enough, I'm not a real programmer but I usually get that error whenever I need to define a specific component :p
     
  6. chrisw

    chrisw

    Joined:
    Apr 25, 2010
    Posts:
    3
    Aw crud - so just no go on the iPhone huh? I tried the time scale solution as a substitute. When it's simulating in unity it works fine, but it freaks out in the compiled app running on the iPhone.

    Another solution I tried was sending out a burst of particles in the Awake at a high speed and then in the Start setting the emitter parameters back to normal. The problem I had with this solution was that I couldn't get the first burst to slow down. I tried targeting them by looping through the particleEmitter.particles array and setting their velocity.x to a lower number, but it doesn't work - they just fly off into oblivion.

    Are there any other workarounds that I should try?

    Thank you very much for the input Eric and Pirate -- I really appreciate the assistance!
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    For now...I would guess that it will work on Unity iPhone 3.0.

    --Eric
     
  8. chrisw

    chrisw

    Joined:
    Apr 25, 2010
    Posts:
    3
    Ah well, I came up with a less processor intenstive solution anyway, so maybe it was for the best :)

    Thanks again for the help!