Announcement

Collapse
No announcement yet.

Particle Engine

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Particle Engine

    This is not exactly about scripting, but somehow related: the new particle engine.

    You can define and fire particle emitters inside .bani animation files:
    - Create emitters, with one or more particle templates
    - Fire the emitter with command "emit" inside single animation frames, or as a cascade action in particles. Or just define a position and an interval, then the emitter will fire automatically each few moments.
    - Use the effects-array to define how the particles change over time, such as fading out or zooming out.

    Example:

    Code:
      "emitters": {
        "1": {
          "relative": true,
          "quantity": 30,
          "limit": 300,
          "draworder": "down",
          "sound": ["crack"],
          "soundchance": 100,
    
          "particles": [
            {
              "lifetime": [0.9,1.3],
              "image": "bbuilder_streak.png",
              "mode": "add",
              "alpha": 1,
              "zoom": 0.9,
              "red": [0.6, 1],
              "green": [0.6, 1],
              "blue": 1,
              "angle": [0, 360],
              "speed": 192,
              "emitatend": 2,
    
              "effects": [
                {"type":"range","time":[0.5,1],"attr":"alpha","mode":"replace","value":[1,0.5]},
                {"type":"range","time":[0.8,1.3],"attr":"zoom","mode":"replace","value":[0.9,0.2]}
              ]
            }
          ]
        },
        "2": {
          "relative": true,
          "quantity": 5,
          "limit": 300,
          "draworder": "down",
          "sound": ["crack"],
          "soundchance": 10,
    
          "particles": [
            {
              "lifetime": 1,
              "image": "bbuilder_flare.png",
              "mode": "add",
              "alpha": 1,
              "zoom": [0.4, 0.5],
              "red": [0.2, 0.5],
              "green": 0.6,
              "blue": 1,
              "angle": [0, 360],
              "speed": 64,
    
              "effects": [
                {"type":"range","time":[0.2,1],"attr":"alpha","mode":"replace","value":[1,0]}
              ]
            }
          ]
        }
      },
    Firing the emitter: you can specify which emitter to fire, and at which position it should spawn the particles. As alternative you can also just type "emit":1, then it will fire emitter 1 at the position of the emitter.

    Code:
      "frames":[
        {
          "directions": [
            [[2,0,2], [5,-48,-207]]
          ],
          "duration": 500,
          "emit": [{"emitter":"1", "position":[16,0,144]}]
        }
      ];
    Last edited by Stefan; 07-06-2017, 09:28 PM.
    Also known as Daddy and bomber
Working...
X