ParticleService

Provides the ability to summon particles.

# Methods

[{"index":"integer PlayAreaParticle(AreaParticleType particleType, Vector2 areaSize, Entity instigator, Vector3 position, float zRotation, Vector3 scale, boolean isLoop = false, Dictionary options = nil)","0":"Activates an AreaParticle at a fixed location on the current map and returns a serial number for removing the effect. The areaSize value specifies the creation range. Returns 0 if creation fails."}]

[{"index":"integer PlayAreaParticleAttached(AreaParticleType particleType, Vector2 areaSize, Entity parentEntity, Vector3 localPosition, float localZRotation, Vector3 localScale, boolean isLoop = false, Dictionary options = nil)","0":"Activates the AreaParticle attached to parentEntity and returns a serial number for removing the effect. The areaSize value specifies the creation range. Returns 0 if creation fails."}]

[{"index":"integer PlayBasicParticle(BasicParticleType particleType, Entity instigator, Vector3 position, float zRotation, Vector3 scale, boolean isLoop = false, Dictionary options = nil)","0":"Plays the BasicParticle at a fixed location on the current map and returns a serial number for removing the effect. Returns 0 if creation fails."}]

[{"index":"integer PlayBasicParticleAttached(BasicParticleType particleType, Entity parentEntity, Vector3 localPosition, float localZRotation, Vector3 localScale, boolean isLoop = false, Dictionary options = nil)","0":"Plays the BasicParticle attached to parentEntity and returns a serial number for removing particles. Returns 0 if creation fails."}]

[{"index":"integer PlaySpriteParticle(SpriteParticleType particleType, string spriteRUID, Entity instigator, Vector3 position, float zRotation, Vector3 scale, boolean isLoop = false, Dictionary options = nil)","0":"Activates a SpriteParticle at a fixed location on the current map and returns a serial number for removing the effect. The spriteRUID value specifies the particle's sprite. Returns 0 if creation fails."}]

[{"index":"integer PlaySpriteParticleAttached(SpriteParticleType particleType, string spriteRUID, Entity parentEntity, Vector3 localPosition, float localZRotation, Vector3 localScale, boolean isLoop = false, Dictionary options = nil)","0":"Activates a SpriteParticle attached to parentEntity and returns a serial number for removing the effect. The spriteRUID value specifies the particle's sprite. Returns 0 if creation fails."}]

[{"index":"void RemoveParticle(integer serial)","0":"Removes the effect with the serial number obtained when playing the particle."}]

##### inherited from Service:

[{"index":"EventHandlerBase ConnectEvent(string key, IScriptFunction eventHandler)","0":"Links events. When a key-type event occurs in this service, a handler is notified. The handler receives event parameters."}]

[{"index":"EventHandlerBase ConnectEvent(Type eventType, IScriptFunction eventHandler)","0":"Links events. This service notifies a handler when an eventType event occurs. The handler receives event parameters."}]

[{"index":"boolean DisconnectEvent(string key, EventHandlerBase eventHandler)","0":"Disconnects the event with the key-type event and the handler."}]

[{"index":"boolean DisconnectEvent(Type eventType, EventHandlerBase eventHandler)","0":"Disconnects the eventType event from its handler."}]

[{"index":"void SendEvent(EventType sendEvent)","0":"Generates an event."}]

# Examples

This is an example of implementing the player's double jump and skill effects with particles.
    
    
    @Component
    script PlayerAbilityHandler extends Component
        property number ParticleSerial = 0
    
        @EventSender("Service", "InputService")
        handler HandleKeyDownEvent(KeyDownEvent event)
        -- Parameters
        local key = event.key
        --------------------------------------------------------
        if key == KeyboardKey.Space or key == KeyboardKey.LeftAlt then
        	if not self.Entity.RigidbodyComponent:IsOnGround() then
        	local lookDirectionX = self.Entity.PlayerControllerComponent.LookDirectionX
        	self.Entity.RigidbodyComponent:SetForce(Vector2(lookDirectionX * 5, 3))
    
        	local options = {
        		["SortingLayer"] = self.Entity.AvatarRendererComponent.SortingLayer,
        		["Color"] = Color(0.25,0.5,0.5,0.8)
        	}
        	local pos = self.Entity.TransformComponent.Position
    
        	_ParticleService:PlayBasicParticle(BasicParticleType.PillarBurst, self.Entity, pos, 90 * lookDirectionX, Vector3.one, false, options)
        	end
        elseif key == KeyboardKey.Q then
        	self.ParticleSerial = _ParticleService:PlaySpriteParticleAttached(SpriteParticleType.StreamSharp, "000000", self.Entity, Vector3.zero, 0, Vector3.one, true)
        end
        end
    
        @EventSender("Service", "InputService")
        handler HandleKeyUpEvent(KeyUpEvent event)
        -- Parameters
        local key = event.key
        --------------------------------------------------------
        if key == KeyboardKey.Q then
        	_ParticleService:RemoveParticle(self.ParticleSerial)
    
        	local pos = self.Entity.TransformComponent.Position
        	local options = {
        		["SortingLayer"] = self.Entity.AvatarRendererComponent.SortingLayer,
        		["Color"] = Color(0.25,0.5,0.5,0.8),
        		["ParticleSize"] = 3,
        		["ParticleCount"] = 2
        	}
    
        	_ParticleService:PlaySpriteParticle(SpriteParticleType.BurstNova, "000000", self.Entity, pos, 0, Vector3.one, false, options)
        end
        end
    end
    

# SeeAlso

  * AreaParticleComponent
  * AvatarRendererComponent
  * BaseParticleComponent
  * BasicParticleComponent
  * PlayerControllerComponent
  * RigidbodyComponent
  * SpriteParticleComponent
  * TransformComponent
  * KeyboardKey
  * KeyDownEvent
  * Color
  * Vector2
  * Vector3
  * InputService
  * [Using Particles](/docs?postId=1036)
  * [Utilizing Particles](/docs?postId=764)