|
|
(3 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | ==Members==
| + | This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/sparticlesystem |
− | {{ScriptFunction|void|Clear|();|Remove all particles in the Particle System.
| + | |
− | | + | |
− | This method also removes the particles from any linked sub-emitters. Use the withChildren parameter to remove particles from child Particle Systems that are not sub-emitters of the system.|5= | + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--remove all particles, parameter you passed to decide whether clear children as well.''<br>
| + | |
− | particles.Clear(true)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|void|Clear|(bool withChildren);|Remove all particles in the Particle System.
| + | |
− | | + | |
− | This method also removes the particles from any linked sub-emitters. Use the withChildren parameter to remove particles from child Particle Systems that are not sub-emitters of the system.|5=spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--remove all particles, parameter you passed to decide whether clear children as well.''<br>
| + | |
− | particles.Clear(true)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|void|Emit|(int count);|Emit 'count' particles immediately.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set max particles to 100 and emit 20 particles.''<br>
| + | |
− | particles.MaxParticles = 100<br>
| + | |
− | particles.Emit(20)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|bool|IsAlive|(bool withChildren);|Returns True if the Particle System contains live particles or is still creating new particles. False if the Particle System has stopped emitting particles and all particles are dead.
| + | |
− | Parameter withChildren: checks all child Particle Systems as well.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--output whether particle system contains live particles or active to procedure particles.''<br>
| + | |
− | Space.Log(particles.IsAlive(true))
| + | |
− | }}
| + | |
− | | + | |
− | | + | |
− | {{ScriptFunction|void|Pause|();|Pauses the system so no new particles are emitted and the existing particles are not updated.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--pause particle system, parameter you passed to decide whether pause children as well.''<br>
| + | |
− | particles.Pause(true)
| + | |
− | }}
| + | |
− | {{ScriptFunction|void|Pause|(bool withChildren);|Pauses the system so no new particles are emitted and the existing particles are not updated.
| + | |
− | Parameter: withChildren: Pauses all child Particle Systems as well.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--pause particle system, parameter you passed to decide whether pause children as well.''<br>
| + | |
− | particles.Pause(true)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|void|Play|();|Sets the Particle Systems into play mode and enables emitting (if it has been disabled).
| + | |
− | | + | |
− | If the Particle System has been paused, then this resumes playing from the previous time.
| + | |
− | If the Particle System has stopped, then the system starts from time 0, and, if it is relevant, the startDelay is applied.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--start particle system to play, you can give a bool parameter to decide whether play children as well.''<br>
| + | |
− | particles.Play(true)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|void|Play|(withChildren);|Sets the Particle Systems into play mode and enables emitting (if it has been disabled).
| + | |
− | | + | |
− | If the Particle System has been paused, then this resumes playing from the previous time.
| + | |
− | If the Particle System has stopped, then the system starts from time 0, and, if it is relevant, the startDelay is applied.
| + | |
− | Parameter withChildren: Plays all child Particle Systems as well.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--start particle system to play, you can give a bool parameter to decide whether play children as well.''<br>
| + | |
− | particles.Play(true)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|void|Simulate|(float time);|Fast-forwards the Particle System by simulating particles over 'time' seconds, then pauses it.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--similate to 3 seconds and pause.''<br>
| + | |
− | particles.Simulate(3)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|void|Stop|();|Stops playing the Particle System.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--stop particle system, you can give a bool parameter to decide whether stop children as well.''<br>
| + | |
− | particles.Stop(true)
| + | |
− | }}
| + | |
− | {{ScriptFunction|void|Stop|(bool withChildren);|Stops playing the Particle System.
| + | |
− | Parameter withChildren: Plays all child Particle Systems as well.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--stop particle system, you can give a bool parameter to decide whether stop children as well.''<br>
| + | |
− | particles.Stop(true)
| + | |
− | }}
| + | |
− | | + | |
− | | + | |
− | | + | |
− | ==Properties==
| + | |
− | {{ScriptFunction|float|Duration|{ get; }|The duration of the Particle System in seconds.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--subscribe to update, to output duration per frame.''<br>
| + | |
− | function OutputDuration()<br>
| + | |
− | Space.Log(particles.Duration)<br>
| + | |
− | end<br>
| + | |
− | spawningparticles.SubscribeToEvents()<br>
| + | |
− | spawningparticles.OnUpdate(OutputDuration)<br>
| + | |
− | particles.Play()
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|float|EmissionRateOverDistance|{ get;set; }|The rate at which the emitter spawns new particles over distance.
| + | |
− | The emitter only spawns new particles when it moves.|5=
| + | |
− | Parameter withChildren: Plays all child Particle Systems as well.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set emission rate overtime to 10.''<br>
| + | |
− | particles.EmisstionRateOverDistance = 10
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|float|EmissionRateOverTime|{ get;set; }|The rate at which the emitter spawns new particles over time.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set emission rate overtime to 10.''<br>
| + | |
− | particles.EmissionRateOverTime = 10
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|bool|EnableEmission|{ get;set; }|When set to false, the Particle System will not emit particles.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--disable emission.''<br>
| + | |
− | particles.EnableEmission = false
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|float|GravityModifier|{ get;set }|A scale that this Particle System applies to gravity.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set gravity modifier to 1, as normal gravity.''<br>
| + | |
− | particles.GravityModifier = 1
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|bool|IsEmitting|{ get; }|Determines whether the Particle System is emitting particles.
| + | |
− | A Particle System may stop emitting when its emission module has finished, it has been paused or if the system has been stopped.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--stop particle system and output emitting status.''<br>
| + | |
− | particles.Pause(true)<br>
| + | |
− | Space.Log(particles.IsEmitting)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|bool|IsPaused|{ get; }|Determines whether the Particle System is paused.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--pause particles and output particle is paused status.''<br>
| + | |
− | particles.Pause(true)<br>
| + | |
− | Space.Log(particles.IsPaused)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|bool|IsPlaying|{ get; }|Determines whether the Particle System is playing.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--output is playing status.''<br>
| + | |
− | Space.Log(particles.IsPlaying)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|bool|IsStopped|{ get; }|Determines whether the Particle System is stopped.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--stop particles and output particle is stopped status.''<br>
| + | |
− | particles.Stop(true)<br>
| + | |
− | Space.Log(particles.IsStopped)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|bool|Loop|{ get;set; }|Specifies whether the Particle System is looping.
| + | |
− | If you disable looping on a playing Particle System, it stops at the end of the current loop.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set particle system looping to false.''<br>
| + | |
− | particles.Loop = false
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|int|MaxParticles|{ get;set; }|The maximum number of particles to emit.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set max particles to 100.''<br>
| + | |
− | particles.MaxParticles = 100
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|int|ParticleCount|{ get; }|The current number of particles.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set a coroutine to check out particle count per period.''<br>
| + | |
− | local function ToCheckParticleCount()<br>
| + | |
− | coroutine.yield(10)<br>
| + | |
− | Space.Log(particles.ParticleCount)<br>
| + | |
− | end<br>
| + | |
− | Space.Host.StartCoroutine(ToCheckParticleCount)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|float|PlaybackSpeed|{ get;set; }|The playback speed of the Particle System. 1 is normal playback speed.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set playback speed to 2.''<br>
| + | |
− | particles.PlaybackSpeed = 2
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|bool|PlayOnAwake|{ get;set; }|If set to true, the Particle System will automatically start playing on startup.
| + | |
− | Note that this setting is shared between all Particle Systems in the current particle effect.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--disable play on awake.''<br>
| + | |
− | particles.PlayOnAwake = false
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|uint|RandomSeed|{ get;set; }|Override the random seed used for the Particle System emission.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set random seed.''<br>
| + | |
− | particles.UseAutoRandomSeed = false<br>
| + | |
− | particles.RandomSeed = 123456
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|Scolor|StartColor|{ get;set; }|The initial color of particles when the Particle System first spawns them.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set start color as pure red.''<br>
| + | |
− | particles.StartColor = Color.New(1,0,0,1)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|float|StartDelay|{ get;set; }|Start delay in seconds.
| + | |
− | Use this to delay when playback starts on the system.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set start delay property to 5.''<br>
| + | |
− | particles.StartDelay = 5
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|float|StartLifetime|{ get;set; }|The total lifetime in seconds that particles will have when emitted. When using curves, this value acts as a scale on the curve. This value is set in the particle when it is created by the Particle System.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set start lifetime to 20 seconds.''<br>
| + | |
− | particles.StartLifetime = 20
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|float|StartRotation|{ get;set; }|The initial rotation of particles when emitted. When using curves, this value acts as a scale on the curve.
| + | |
− | Note that the value should be given in radians.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set start rotation to 90 degrees.''<br>
| + | |
− | particles.StartRotation = 90
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|SVector|StartRotation3D|{ get;set; }|The initial 3D rotation of particles when emitted. When using curves, this value acts as a scale on the curves.
| + | |
− | Note that the values are Euler angles and should be given in radians.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set start rotation to 90 degrees of Y axis and 90 degrees of Z axis.''<br>
| + | |
− | particles.StartRotation3D = Vector.New(0,90,90)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|float|StartSize|{ get;set; }|The initial size of particles when the Particle System first spawns them.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set start size to 10.''<br>
| + | |
− | particles.StartSize = 10
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|float|StartSpeed|{ get;set; }|The initial speed of particles when the Particle System first spawns them.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--set start speed to 10.''<br>
| + | |
− | particles.StartSpeed = 10
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|float|Time|{ get;set; }|Playback position in seconds.
| + | |
− | Use this to read current playback time or to seek to a new playback time.|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--particle start to play at seconds 2.''<br>
| + | |
− | particles.Play(true)<br>
| + | |
− | particles.Time= 2
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|bool|UseAutoRandomSeed|{ get;set; }|Controls whether the Particle System uses an automatically-generated random number to seed the random number generator.
| + | |
− | If set to true, the Particle System will generate a new random seed each time it is played. If set to false, ParticleSystem.randomSeed will be used instead, allowing for a constant seed (useful if you want your particles to play in exactly the same way each time) or user-defined random value (for example, you may want to cycle through an array of seeds).|5=
| + | |
− | spawningparticles = Space.Scene.Find("Particles")<br>
| + | |
− | ''--get particle object and get the particle system component on it.''<br>
| + | |
− | particles=spawningparticles.ParticleSystem<br>
| + | |
− | ''--disable UseAutoRandomSeed.''<br>
| + | |
− | particles.UseAutoRandomSeed = false
| + | |
− | }}
| + | |
− | | + | |
− | {{Scripting Navbox}}
| + | |