- Home /
Question by
JulienBe · Nov 02, 2014 at 10:10 AM ·
androidparticleemitter
Changing emission rate only works once on mobile
Hi guys ! I have a problem, I want to change the emission rate of a particle emitter :
It's supposed to emit more smoke when the ship does up, and less smoke when it goes down. It works perfectly on desktop. But on Android, it only increase the first time I launch the game, and then it stays at max :/
Here the code that control the thruster :
public ParticleSystem[] smokes;
private float[] initialRateSmokes;
public Light light;
private float initialLightIntensity;
void Start() {
initialRateSmokes = new float[smokes.Length];
for (int i = 0; i < smokes.Length; i++)
initialRateSmokes[i] = smokes[i].emissionRate;
initialLightIntensity = 3.43f;// light.intensity;
}
public void increase() {
for (int i = 0; i < smokes.Length; i++)
smokes[i].emissionRate = initialRateSmokes[i] * 5;
light.intensity = initialLightIntensity * 5f;
}
public void decrease() {
for (int i = 0; i < smokes.Length; i++)
smokes[i].emissionRate = 5;// initialRateSmokes[i] * 0.1f;
light.intensity = initialLightIntensity * 0.1f;
}
public void stable() {
for (int i = 0; i < smokes.Length; i++)
smokes[i].emissionRate = 40;// initialRateSmokes[i];
light.intensity = initialLightIntensity;
}
And here is the player controller that calls it :
private void move(Vector3 mvt) {
if (mvt.y > 0.01f) {
thrusterController.increase();
} else if (mvt.y < 0.01f) {
thrusterController.decrease();
} else {
thrusterController.stable();
}
....
}
void Update () {
if (Input.touchCount > 0) {
if (Input.touches[0].phase == TouchPhase.Began) {
originTouch = Input.mousePosition;
} else if (Input.touches[0].phase == TouchPhase.Moved) {
Vector3 mvt = Input.mousePosition - originTouch;
move(mvt);
}
}
// PC
// JUST TOUCHED
if (Input.GetMouseButtonDown(0)) {
originTouch = Input.mousePosition;
// TOUCHED
} else if (Input.GetButton("Fire1")) {
Vector3 mvt = Input.mousePosition - originTouch;
move(mvt);
}
}
The ship moves perfectly so the move method is called as it should be. And once again it's perfect on desktop -.- Does someone have an idea ?
Thanks for your time !
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613170527im_/https://answers.unity.com/themes/thub/images/avi.jpg)