- Home /
Enable and Disable Particle Transforming to Random Position when Disabled
Hi,
We are developing our weather system and we are trying to feature lightning bolts. Only problem is our system is proving difficult to enable the particle for the lightning because it's based off reaching random numbers.
We want the lightning bolt or particle which is a game object, that is applied manually, to emit for at least 1 second. We've gotten the particle to be enabled when the system tells it to, but only for a split second.
We also want the lightning to transform to a random position when it's disabled so it's in a different position every time it's enabled.
Is there a way to control how long the particle emits? We've also tried this but it messes with our system and causes it not to work properly.
//lightning bolt is applied here
var lightningBolt : Renderer;
//position inside circle
var newPosition : Vector2 = Random.insideUnitCircle * 5;
if (//random number is reached)
lightningBolt.enabled = true;
if (lightningBolt.enabled == true)
{
//This seems to be causing the problems.
yield WaitForSeconds (1);
}
else
lightningBolt.enabled = false;
transform.position.x = newPosition.x;
transform.position.y = newPosition.y;
We need a way to do the above, if anyone has a better way or has a way to help us out that'd be great. And like always we will be sure to check as answered.
Thanks guys