SpoocyCrep
SpoocyCrep

Reputation: 614

Emit at a certain position doesn't work?

I want to emit particles at a certain position without having to move the Particle System. I found this: https://docs.unity3d.com/ScriptReference/ParticleSystem.EmitParams-position.html

I tried that, but it doesn't emit at the position I want instead it emits them at 0,0,0 where particle emitter is located!

   var emitParams = new ParticleSystem.EmitParams();
                emitParams.position = keyValue.Key;
                emitParams.velocity = new Vector3(0.0f, 0.0f, 1.0f);
                SmokeParticles.Emit(emitParams, 100);

keyValue.key is a vector that holds the correct position. Am I missing something?

Upvotes: 1

Views: 1322

Answers (1)

Assafs
Assafs

Reputation: 3275

The Unity editor has a lot of attributes in the Particle System setup, one of which is "play on awake", which makes sure the particle system is on from the start. You could simply put:

SmokeParticles.Stop();

Before the override code section, and then the (0,0,0) particle system will be turned off. The Emit call you make should show the position you chose. For testing purposes, I would also add to the EmitParams:

emitParams.startColor = Color.red;

Just to highlight the override emission.

Also, for repeating emissions (to better reproduce the original result) have a look at this example from the documentation:

Particle System Emit Documentation.

Upvotes: 1

Related Questions