Search Unity

Particle Playground

Discussion in 'Assets and Asset Store' started by save, Dec 4, 2013.

  1. primus88

    primus88

    Joined:
    May 14, 2013
    Posts:
    611
    Ok man, I will bother you a bit when you launch it. I will have a couple of questions there.

    Oh and you are insanely good with making promotional material!
     
  2. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Make sure you do! Fastest way is through support@polyfied.com. Thanks I'm glad you like it. :)
     
  3. jnas

    jnas

    Joined:
    Jul 13, 2013
    Posts:
    7
    Epic video, works really well!

    in the meantime I have a question. Not sure if it's the appropriate time for this though, please pardon me if it's not.

    I'm really into the Source - State, using it with textures. I really love the transitions between states and think how useful it would be to have more control over the transitions. Say I have 10 textures/states, I would love to have one float which controls the time in-between the states. 0.0 would be state 0 and 1.0 would be state 1, and 0.5 would be in the middle of those. Going up from 0.5 to 8.5 and I would go past all states and arrive in-between 8 and 9. That way I could use iTween instead of Lerp and I could go up from 0. to 9. with as many steps and eases in-between as I prefer.

    Since I'm quite new to Unity and assets like yours I am not sure if this could/should be a feature request or should I dive into the code and do it myself. (which I gave a shot, found the place where to fiddle but not sure how to get it working yet). Can you give any direction?
     
  4. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200
    Hi save,
    the trailer is stunning. Since i only use Unity Free i would like to know if i can achive the same especialy regarding the glow effects.

    Thanks a lot!
     
  5. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Thanks!

    That's alright, and I like the idea. I do have some bittersweet news in that area where in 2.0 state transitions is being replaced with snapshots as that gives way better control over the final presentation. This was a call I had to make as transitions was far too secluded and difficult to implement with the rest of the system. In 2.0 you'll first create a state, then create a snapshot which will have all your particle system's settings for that particular state.
    If you rely heavily on 1.20's state transitions in the middle of a project I'd suggest to not update to 2.0 yet. But when you do I believe you'll benefit a lot in the level of control you'll get over the whole particle system (transitions also have ease-in/ease-out if you need).

    Using 1.20 you could script the transition speed, where you'll set PlaygroundParticles.transitionTime in-between transitions. Making use of coroutines you could yield for as long as a transition lasts then set the next transitionTime. Hope it makes sense - please ask if you need more details!

    I like the idea to add individual transition values, I'll have a look into that for snapshots for sure!
     
  6. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Hey red2blue, glad you like it! A lot can actually be done with particles and their textures (would be my best answer). The godrays and small amount of bloom is from using the Unity Pro's post-effect library though.
     
  7. jnas

    jnas

    Joined:
    Jul 13, 2013
    Posts:
    7
    Hi Save, Thanks for explaining. I'm most certainly going for 2.0, not in the middle of a big project but exploring opportunities for an upgrade. Patiently waiting for the snapshots.. :)
     
  8. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200
    Hi save,

    thanks for the quick reply! Is the scene from the Video, or a few examples included in 2.0 so i could run it on Unity free to see how it looks and what is possible?

    I bought your package a year ago but i never really used it. This Video really showed me what i was missing (even if there are new features too).
    Thanks for improving the package!!

    Cheers!
     
  9. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    @Save
    Great tool. I had reason to believe in you. :p
     
  10. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Alright super and thanks for the feedback! I'll have a look into how we can evolve snapshots.

    Sure thing! Some of them are in (with a couple of other more technical examples), some of them were made in all haste for the video only. Glad it gave inspiration your way.

    Haha thanks ZJP, you did from the very beginning yes. :)
     
    Last edited: Jul 10, 2014
  11. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    That went live faster than I had imagined, so here's what's new! (see full update here)



    The video in case you missed it last page:


    Performance
    Playground has been given a couple of more gears. Most of the code is revised and adapted for multithreading where every particle system will run on its own thread. Some demanding features such as turbulence and skinned meshes opens up yet another. How data is iterated has been improved greatly and you'll have more power left for other logic.

    Turbulence
    Now you have access to both order and chaos. There's two turbulence algorithms available of type Simplex- and Perlin noise. Simplex noise will produce a natural branch pattern and Perlin noise will have a more confined wave-like pattern. The turbulence iterates over the whole scene where you can set strength, resolution scale, time (animation speed of the algorithm) and lifetime strength set by curves.

    Event System
    Events will make particle systems talk to one another and any of your game logic through event delegates. This can for instance be used to create smoke trails from single particles or compromise a character's health upon collision. Available particle events are birth, collision, death and time (repeat by timer).

    Snapshots
    A snapshot is a saved state of a particle system's settings and live particles within the scene. This can be loaded by any particle system where you have the ability to transition from current- to next settings. Snapshots replaces the previous state transitions which was secluded to states only. This can also be used to start a particle system from a predetermined state live in the scene.

    2D Collisions
    A Collision Type is introduced where you can choose between 2D- and 3D collisions. Collision methods for source mode Paint and Projection is also available.

    Vortex Manipulator
    A new velocity manipulator is introduced which simulates a swirling vortex. The swirl direction is based on the manipulator’s transform upward axis, changing direction is just a matter of rotating the transform.

    Mesh Target Manipulator
    Now you can send particles toward mesh vertices within the scene. Skinned meshes are supported as well with the Skinned Mesh Target. The Mesh Target have property abilities where you can choose to either immediately set particles towards their target or transition in form of strict linear or linearly interpolated movement. Use Target Sorting to distribute target positions in a linear or scrambled fashion.

    Lifetime Colors
    Introducing a list of lifetime colors as Color Source where you can set as many gradients as you please. Each particle will get paired with a gradient upon birth.

    Pause calculation outside of camera view
    To optimize what’s being calculated you can now determine if a particle system should stop when not in view.

    Enhanced GUI and workflow
    It’s easier to manage your particle systems now through the improved home-screen of Particle Playground. Presets are divided into ”User” and ”Examples”, all ”User” presets will be exported to the final build of the project whereas an ”Example” won’t. Should you want to use InstantiatePreset(”preset name”) on an ”Example” preset you need to press the button ”Convert to User” found in the list presentation mode.


    As expected, full source is still available for you to edit and improve.
    For more information please refer to the official site playground.polyfied.com where demos and a thorough manual is available.


    Transitioning from a previous Playground version
    First, make sure you do a backup of your project before updating. Due to the heavily rewritten code and multithreading support some changes has been a necessity. Some parts will need manual updating.

    1) Any manipulator needs to be reassigned to their transform.
    2) As State transitions has been replaced with Snapshots you can no longer rely upon that feature - however you'll gain more control using Snapshots.
    3) Script mode particle parenting is no longer available. I'm looking into rebuilding a better structure but it needs another production cycle.
    4) If you install without removing the previous Particle Playground folder, here's the assets to move:
    a) Resources/Csharp/Particle Playground System.prefab and Playground Manager.prefab to Resources/
    b) Resources/Csharp/Brushes/ to Playground Assets/Brushes/.
    c) Resources/Csharp/Presets/ to Playground Assets/Presets/ where any of your own presets you wish to instantiate at runtime should be moved to Resources/Presets/.

    Given you've been using the C# version of Particle Playground you should be able to install upon the previous version to have particle systems detain their serialized settings. However, it's recommended to start clean where you remove the previous Particle Playground folder (exclude any presets) as 2.0 has a new structure. Any presets you intend to instantiate through InstantiatePreset("name") must be of type User and placed in the Resources/Presets/ folder - this is to not export any unnecessary dependency assets to your final project from the Example presets.
    If you're in the middle of a project and need much manual updating please evaluate if you will gain from the new features and changes in 2.0.

    When scripting make sure you're using the namespace ParticlePlayground at the top of your scripts, as such:
    Code (csharp):
    1.  
    2. using ParticlePlayground;
    3.  
    4. public class YourScript : MonoBehaviour {}
    5.  
    For further guidance please open a support errand at support@polyfied.com.
     
    Last edited: Jul 10, 2014
  12. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    this is really nice.. I've been looking for a solution that uses Shuriken for all platforms (besides just DX11) and well.. :)


    a couple questions though:

    - I'm unable to use the webplayer demos on the SurfaceRT (ARM device) as the player isn't compatible for that platform apparently. Any downloadable demos for ARM (Windows 8.1/ RT)?

    - and on that note, is it Windows Store Application and Windows Phone 8 compatible?

    - what will be upgrade cost if license is purchases now for when Unity 5.x is released?
     
  13. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Super! Welcome aboard when ready. :)

    I'll have a look into adding some downloadable demos (currently a bit swamped though), it's a good request. Compatibility across all platforms. No upgrade cost, one time purchase then you're all set.
     
  14. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    thanks for the quick reply.. i'm sold. look forward to the demos.. or maybe i'll just have to give it a go now myself lol..
     
  15. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    Congratulations with the release of Particle Playground 2! Quite a huge jump in performance and features.
     
  16. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Haha, well I'll try my best to have something downloadable to device, but it's a bit till I can jump onto that.

    Thanks movra! Was a really intense production sprint this one. :) I really appreciate your time and all super feedback during the beta!
     
  17. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Minor issue found, if you're looking to add force to rigidbodies in 2d before next update you need to change line 2200 in PlaygroundParticlesC.cs where it says hitInfo to hitInfo2D.
     
  18. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Update 2.0.2 sent to the Asset Store for review, fixing a couple of minor issues and adding more control to Snapshots.
    See the version history doc for more info.
     
    red2blue likes this.
  19. MightyShad

    MightyShad

    Joined:
    Jul 17, 2014
    Posts:
    1
    Is it possible to use a sprite sheet in Particle Playground 2? Similar to the way it works with Shuriken.
     
  20. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Yes, although not as intuitively as I would have liked to structure it. You need to enable the Shuriken component's visibility through Playground Manager > Advanced > Show Shuriken. The Playground will send lifetime data back to the Shuriken component to enable sprite sheet animation. Please see this post for more details: http://forum.unity3d.com/threads/particle-playground.215154/page-3#post-1542678
     
  21. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Looking into adding compatibility for Windows 8 apps which uses a different method for threading. Anyone with a Windows 8 phone/tablet who could provide some beta testing?
     
  22. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    just sent you a message via your contact form at Polyfied....
     
  23. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Perfect, thank you!
     
  24. cspeer504

    cspeer504

    Joined:
    Sep 26, 2012
    Posts:
    11
    Hello. I just purchased this and haven't yet made any creations of my own, but I've been playing with the example scenes to get a feel of how changing different values change the behavior of these examples. I opened up the "logo example" and changed the particle systems "Source->State[0]->Texture" with my logo.png texture. I enabled read/write for the texture when prompted and got it to work. The problem I have, is that the particle system only rendered the bottom half of my logo texture. After troubleshooting I noticed that the example logo "Particle-Playground-2" was of size 512x64 and my logo was of size 512x128. I resized my logo to 256x64 and it worked perfectly. I read the whole PDF doc down to page 32 so I'm familiar with all the inspector options, but couldn't find one to get this larger texture working. I also checked out the PlaygroundLogoExample.cs script and couldn't find anything that would be limiting particle play on only 64 pixel heights.

    Question is: How do I get the 512x128 (or any other different sized texture) to work with the full particle system? You can easily reproduce by making any texture of 512x128 size and plopping it in there. Here is a screenshot of what I see with an generic example texture I cooked up:

    Texture: https://www.dropbox.com/s/zeu9ue9q3c3wwg0/TestImage1.png

    Behavior: https://www.dropbox.com/s/n3rjr10qzybbtwn/TestImage2.png
     
  25. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Hey there!

    Reason is that you don't have enough particles to cover for your amount of pixels (65536).
    Press Source -> State[0] -> Set Particle Count or by hand in Particle Settings > Particle Count and you should get the particles to fill up every pixel position.
     
  26. cspeer504

    cspeer504

    Joined:
    Sep 26, 2012
    Posts:
    11
    Well that makes sense. I just immediately assumed texture sampling for sprite positioning was randomly done and didn't even think about doing pixel/particle count. Thanks!

    I'm loving the system! I can tell a lot of hard work and care went into it. Look forward to making my own particles soon!
     
  27. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Great! The sampling is done per pixel from bottom to top, should you need another ratio you need to resample the image in the import settings or any image software. Often you don't need full scale, as that creates a lot of particles to simulate, where instead a sprite and then emit particles on top/behind (much alike what is done on the big name video on playground.polyfied.com, seen on desktop devices).

    I'm glad you like it, let me know when you create something amazing! :)
     
  28. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    334
    Hi Save I've got a question about how particle playground handles drawcall batching. I'm making a game where I need to render 800 glass cubes with glowing mesh numbers in them. I've created the shaders in shader forge and it looks great but doesn't work well on my vita because for some reason unity doesn't batch my glass shaders draw calls. I was assuming it was perhaps because the refractive glass takes more than one draw call so unity can't batch it. If I use the glass shader with your cubism example though it appears to batch correctly and so works fine on vita.

    My question is is particle playground doing something explicitly to perform this batching. Since I need control over each of these blocks in my game for example I need to be able to change the numbers in them and in some situations move them, I was intending to just attach them as game objects to the scene rather than emit them as particles.

    With your events system and new snapshot system I was wondering whether it would be more efficient to control them with particle playground ?

    Since my blocks have 9 states would it make sense for when I create my levels instead of moving the glass blocks I need in my game to instead move a transform with a script attached that instead tells it to add a particle playground particle at that position ?

    Since I have 9 states for the blocks would I create 9 particle systems each configured to emit a mesh particle that looks like the glass block needs to in each state. Then if I needed to change the block type in the game I would use the event system in particle playground to comunicate with the other particle systems to add a new particle to the particle system I need the block to look like and then delete the existing particle ?

    If I did this do you think it would batch for each particle system so that in the worst case I would have 18 draw calls for my glass vs 6400 ?

    Do you think this would work or do you have any better suggestions ? Would it be more efficient to use snapshots for example ? Also are there any snapshot examples included as I couldn't see any ? If I want to transition between completely different particle systems like you did in your web example how do you set this up, I can use the snapshots to vary the colour of a particle system but am unsure how you use it to more to a completely different system ?
     
  29. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Hey Ian!

    There's nothing extra which happens regarding batching in Playground, the reason is that the particle system is rendering the cubes as a single combined mesh (800 cubes of 24 vertices should be a single drawcall with a basic mobile optimized shader). If not using a particle system, as long as you use the same material instance, don't use multi-pass shaders (which may be your case) and don't separately scale the meshes (unless non-uniform) you should have dynamic batching running on your device. http://docs.unity3d.com/Manual/DrawCallBatching.html

    It does make sense to take advantage of the Playground specific features. The way you create your source positions is up to you - and it depends a bit on how it's currently structured. You can draw your blocks per pixel on a texture if this is a 2D environment and make a State render them out. Another choice is to paint them by hand directly in the tool. If you already have placed your blocks - put a script on them which each calls an Emit() on the particle system, then store the finished emissions into a Snapshot and you'll have them serialized within the particle system. The other way around would be where you let the particle system find your current cubes and emit based upon their position - perhaps this is a finer way of doing it as it will let you sort your cubes on beforehand.

    If your game is within one scene, I'd suggest to store all 9 states within one particle system, then all you need to do is call Load(int) to load up your blocks. One thing though is that you can't have colliders on the particles, so you would have to keep colliders within the scene if your logic demands it.

    Any particle system can transition into a snapshot (positions, sizes, colors, velocities, manipulators etc.). The way I did it in the video was to use one particle system and just have fun with it, save its state when I saw something interesting, then I just stepped through them once I recorded the video. Should you want to add a different particle system you can as well, first store a snapshot of it then switch to advanced mode in Snapshots to expose the GameObjects in hierarchy and their components, basically drag and drop between different particle systems (component needs to be a snapshot, the framework will tell you if you by mistake do it backwards).

    I believe the Event system can do sort of what you're asking, each particle can broadcast an emission into another particle system based upon particle birth, death, collision or time (where time is a repeated timer). There's also an option to let particles send detailed data about themselves into an event delegate which your logic can listen and respond to.
    However I'm getting the picture that you should go the other way around, letting your existing cubes emit into the particle system, to have their colliders remaining (if necessary). You could then let manipulators interact with the particle within the cube positions if you'd like.

    With a proper setup where you have a sorted array of cubes you could also reach into the playgroundCache to let every cube control their corresponding particle, moving it about, changing its size, color etc. It's hard to say exactly what would be best in your particular case, it all depends on what you expect of the final presentation and which kind of flexibility you're looking for.

    How are you doing the numbers inside the blocks, are they sprites?

    There's a Snapshot example in the package, you can find it Examples/Example Scenes/Interactive/. However in the latest release I managed to break snapshots made prior to 2.02 (which the example is) - not great, but a fix is sent waiting for approval which will make all 2.01 snapshots run again.
     
  30. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    ...aaand 2.03 is up!

    This comes with a reworked particle stretching - so you may have to re-tweak your stretching to get any result you had previously. The stretching previously had issued with any manipulators repositioning particles, where stretching now instead calculates from delta position instead of velocity. So for instance, having particles moving towards a target will now make them able to stretch in that direction. You can also set how fast a particle will stretch and what amount of stretch will apply over a particle's lifetime using a normalized AnimationCurve.

    Another addition is the Manipulator Lifetime Filter, where you can determine which particles should be affected by a manipulator using a minimum to maximum lifetime span. This will filter out any particles outside that range to not be affected. This can for instance be used to only apply properties upon a particle's birth, leaving any entering particles into the manipulator's area intact.

    And perhaps best of all, Snapshots should now run as expected. :)

    http://www.polyfied.com/products/particle_playground-versionhistory.pdf
     
    red2blue and tswalk like this.
  31. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    So I bought this asset a while back but haven't used it yet. I'm trying to think of ways I could use it to eventually bring some sweet polish to my game however my game is 2D and all the examples I've seen on this thread are 3d.

    So I guess what I'm asking is has anyone done anything cool with Particle Playground 2 in a 2D game that might be inspirational? and how useable is this product for 2d (can the manipulators be constrained?).

    Also does anyone have comments on mobile performance (yes I know this will likely vary widely depending on what features you are using).
     
  32. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    You're able to constrain any forces applied through selected axis on the particle system. The difference from 3d and 2d is minimal, just take away one axis and work with the built-in 2d physics instead of 3d where applicable. I would also like to see more projects in 2d, I know there are plenty out there through various support errands but none has chosen to showcase yet (except Pixel Garden). Let's see if that can change any time soon given that this is still such a new framework. There are a couple of large projects about to showcase soon but they are in 3d.
    Mobile performance is currently good as long as you don't have too many systems at the same time, but this seems widely varying depending on how well they scale for multithreading. I'll try to finish a comparison chart soon.
     
  33. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    Thanks for the info. I guess I'll just have to play around with it and see what I come up with :D
     
  34. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Go for it! If you bump into any obstacles feel free to ask here. :)
     
  35. cspeer504

    cspeer504

    Joined:
    Sep 26, 2012
    Posts:
    11
    I've had a little more time to play with this particle system and I'm really liking it! I ran into a couple of problems I would like to see if I can get help with (from you or anyone else who sees this post). I've read the whole PDF doc and have checked out the example scripts, but I can't seem to find out what my particular problems may be:

    Note: Before I get into it, I have set up 2 very simple scenes with these problems in it. To setup, first import particle playground package (I don't include any PP2 files in this example package), then import this custom package. I use PP2 version 2.03.

    Problem 1:
    I created a particle system with two snapshots:
    1. The default "fountain" particle
    2. Modified "fountain" particle that bursts using modified velocity and Perlin turbulence.
    I play the first snapshot for default and then want to snap the the second. When I load the second, nothing seems to happen. When I load the first snapshot, it no longer behaves the same as it did before loading the second snapshot. I'd like to A) get the second snapshot to work and B) Be able to snap back to the first snapshot and have it behave as expected.

    Problem 2:
    I created a particle system with two snapshots:
    1. The default "fountain" particle.
    2. Modified "fountain" particle that has 1.5 scaled particles and is multicolored.
    I have a simple move script that makes it constantly move left and right on the screen. When I swap to each snapshot, the particle system's position starts the particle back at the original position and not at the current position. I unchecked the "transform" checkbox for both snapshots in the "Snapshots" inspector group for the "Playground Particles C" script. This made the two snapshots load at the current position like I wanted, but for a brief moment, the particle plays at the original position. I'd like to not have the particle briefly play at the original position if possible. I don't know exactly what the "transform" checkbox does, as the PDF doc doesn't go into detail about that (or the "inherit" option for that matter). So perhaps my lack of understanding is what is keeping me from solving my issue.

    Any help is appreciated :)
     
    Last edited: Aug 3, 2014
  36. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Hey there!
    Glad you have a good impression of it. Thanks for thorough info - that was a really great start to dig into this, I've worked through the examples you gave and I think you've actually run into a bug.
    For problem #1 it seems when loading a snapshot set to burst and not having it looping it will not be timed as expected, however when looping everything runs as normal.
    Problem #2 you could set the snapshots to "Settings Only" as "Settings & Particles" will load up each particle's position when you made the snapshot. However there's an interesting side of this, where if the framework could reposition depending on source delta positions where the particles should be. You'd in that case be able to store a snapshot and move it along its source upon load, seems like there could be some really useful scenarios there so I'll investigate how that could be implemented.
    I'll dig in to #1 ASAP to have it fixed in the next update. Thanks!
     
  37. cspeer504

    cspeer504

    Joined:
    Sep 26, 2012
    Posts:
    11
    #2 works perfect now! I can't believe I missed that combination, I thought I tried them all. :)
     
  38. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Great! I'll let you know when #1 is ready to run. :)
     
  39. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Seems Particle Playground is running for the Unity Awards in Technical Achievement and Community Awards, either your choice don't forget to vote on all awesome projects out there!
     
  40. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Voted. Good luck. :cool:
     
  41. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Thanks ZJP, I'll sure need it competing with those projects. :)
     
  42. Issam

    Issam

    Joined:
    Dec 18, 2012
    Posts:
    37
    Hi, is there a way to pause a particle effect from script? I would like to "freeze it" when a gameplay event happens and "un-freeze" it at a later time. I think I could do that by pausing a shuriken system, but it seems the update of particle playground always force an unpause?

    (sorry if this was asked, I can't seem to figure out how to search in a thread)
     
  43. protoben

    protoben

    Joined:
    Nov 11, 2013
    Posts:
    39
    Hi,
    I have a few questions about the snapshot system

    Is there a way to edit an existing snapshot? clicking save just saves a new one.
    What attributes are saved in a snapshot? It seems like material is not saved in a snapshot. Is there a a list of what is saved and what isn't?
    Lastly, I can not find a "show snapshot" button where the Next manual says it would be:

    "To browse and edit them you can enable Playground Manager > Advanced > Show Snapshots. "

    thanks
     
  44. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Hi Issam,
    I don't think this has been asked previously, but it's a really good question. There's actually no direct intuitive way of freezing the particles as pausing the calculation will currently issue a reboot to make it match the global time. You're right, the framework will keep the Shuriken component simulating if it has stopped or paused to workaround the bug where Shuriken particles may become invisible when the transform is outside of the camera's view (you can still experience this in Scene View).

    It's a really missing piece so I'll be looking into adding this for next update. An interesting addition would be to implement a true local time so you could freeze in a slow-motion fashion or even speed up. I suppose it would also be nice to have thinking of all velocity settings you'd otherwise need to fine-tune on a more advanced system. Let me see what I can do!

    Hi protoben,

    Yes, sorry I've missed updating that section in the manual after the 2.02 update. To edit an existing snapshot you first need to toggle the Snapshots > Advanced button. This will expose the components they are connected to, fine-tuning options for transitions and the most important make the stored snapshots visible in Hierarchy under the particle system.
    Actually it should only be the material which doesn't get stored, otherwise all particle data (entire PlaygroundCache) and all individual settings serialize into a new particle system where the variable isSnapshot determines how it talks to the rest of the framework.
    I could add material change as an option into next update as well, but when using transitions it would simply "snap" into the new material once the snapshot is ready to run. In version 2.03 you need to handle this part by script. Here's an example where you add a material to each corresponding snapshot:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using ParticlePlayground;
    4.  
    5. public class NewMaterialOnLoad : MonoBehaviour {
    6.  
    7.     public int loadSnapshot = 0;
    8.     public Material[] materials;
    9.     PlaygroundParticlesC particles;
    10.  
    11.     void Start () {
    12.         particles = GetComponent<PlaygroundParticlesC>();
    13.     }
    14.  
    15.     void Update () {
    16.         if (Input.GetMouseButtonDown (0))
    17.             StartCoroutine(LoadSnapshot ());
    18.     }
    19.  
    20.     IEnumerator LoadSnapshot () {
    21.  
    22.         // Early out if we're already in a transition
    23.         if (particles.InTransition())
    24.             yield break;
    25.  
    26.         // Load the selected snapshot
    27.         particles.Load (loadSnapshot);
    28.  
    29.         // Yield while in transition
    30.         while (particles.InTransition())
    31.             yield return null;
    32.  
    33.         // Set material
    34.         if (materials.Length>0 && loadSnapshot<materials.Length && materials[loadSnapshot]!=null)
    35.             particles.particleSystemRenderer.material = materials[loadSnapshot];
    36.     }
    37. }
    38.  
    Should you not want to wait for any transitions you could remove the while-loop and set the function to return void instead of IEnumerator.

    Hope it helps!
     
    Last edited: Aug 11, 2014
  45. Issam

    Issam

    Joined:
    Dec 18, 2012
    Posts:
    37
    Hi sage,

    for now I was able to get something working by modifying the way evaluatedLife is calculated for each particle (using playgroundParticles.particleTimescale):

    Code (CSharp):
    1.  
    2. // Calculate lifetime
    3.  
    4. previousEvaluatedLife = playgroundParticles.playgroundCache.life[particleIndex] / playgroundParticles.lifetime;
    5. newWantedEvaluatedLife = (PlaygroundC.globalTime - playgroundParticles.playgroundCache.birth[particleIndex]) / playgroundParticles.lifetime;
    6.  
    7. evaluatedLife = previousEvaluatedLife + ((newWantedEvaluatedLife - previousEvaluatedLife) * playgroundParticles.particleTimescale);
    8.  
    9. //We need to modify the birth and death variable if the time scale changed, mainly because lifetime is calculated based on the difference between globaltime and birth time
    10. playgroundParticles.playgroundCache.birth[particleIndex] += (newWantedEvaluatedLife - evaluatedLife) * playgroundParticles.lifetime;
    11. playgroundParticles.playgroundCache.death[particleIndex] += (newWantedEvaluatedLife - evaluatedLife) * playgroundParticles.lifetime;
    12.  
    I had to make playgroundParticles.particleTimescale a public variable, it seems most of the code is using it correctly already? At least from what I am seeing this seems to work... but I might have broken stuff, we will see :)

    Also this is unrelated, but when creating a preset, I modified the code to use PrefabUtility.ReplacePrefab over CreatePrefab if a prefab already exist, that allow it to not break any connection that objects have with this prefab. I found that ReplacePrefabOptions.ReplaceNameBased is the best option to use for ReplacePrefab. Do you think that will break anything?
     
  46. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Nice going Issam, very clever solution! :)
    That should work from what I can tell, it's not yet a fully implemented feature. When pausing (having it set to 0) the calculation loop will still run, and if setting the variable calculation to false you'll see the Shuriken particles not being able to cope even if you modify their individual lifetime. Why that is I currently don't know but should be an easy fix soon hopefully.
    Have to say I'm not overly joyed with how particle time calculation is done, I should have gone for a value moving towards 0 for more flexibility.

    Going with ReplaceNameBased should work well, thanks for looking into it! Keep in mind when you instantiate a preset from the home screen it will be a new instance though.
     
  47. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    red2blue likes this.
  48. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Whooo!!!
    There are so many things possible with your tool I don't know where to start. Whenever I see a demo, i want to incorporate it into my project. :p
     
  49. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Happy you like where it's going! I'm currently trying to focus a lot on the mechanics around game logic, so we don't get stuck in only using it for visuals. Let's see if we can make some amazing things! :)
     
  50. Mr_Mendel

    Mr_Mendel

    Joined:
    Dec 31, 2013
    Posts:
    19
    Hi,
    I may just being stupid but I cannot seem to get it to work.

    I wan a preset to spawn when i hit something.

    I tried using PlaygroundTmp.InstantiatePreset("Playground Circle Shot (script)");

    but it says - cannot be accessed with an instance reference; qualify with a type name.

    Any help would be appreciative
    Thx Mike