- Home /
Manually Positioning Particles doesn't work
I already looked at this previous question:http://answers.unity3d.com/questions/16088/setting-particle-position-does-not-appear-work.html However even if I set particleEmitter.particles[0].position.x = 5; directly it still does not work. Very puzzled by this. Currently I have attached to a blank gameobject:
a very tiny ellipsoi particle emitter which emits one particle with no velocity, 0 for the minenergy and maxenergy so it never disappears, and oneshot on
a particle renderer with nothing changed
this script:
`function FixedUpdate(){`
a = particleEmitter.particles[0].position.x = 5;
Debug.Log(a);
Debug.Log(particleEmitter.particles[0].position.x);
`}`
The particle does not move, 'a' returns 5, and the second Debug returns the position of the emitter as if the particle had not moved which it hasn't. Can anyone explain? Or provide an example which works?
Answer by Eric5h5 · Jul 25, 2011 at 06:44 PM
As with all cases like this, you have to get a copy, change the copy, then assign it back. (See the docs.)
Thanks for the advice. Sorry I didn't specify clearly I tried the answer given to the other question already: var particle : UnityEngine.Particle; particle = particleEmitter.particles[0]; function FixedUpdate(){ //Debug.Log(particle.position); particle.position.x = 5; particleEmitter.particles[0].position = particle; Debug.Log(particleEmitter.particles[0].position); }
But got the same result. Thanks for the quick reply.
Your answer
![](https://koobas.hobune.stream/wayback/20220612154938im_/https://answers.unity.com/themes/thub/images/avi.jpg)