- Home /
How to move direction of particle(s) emitted by ParticleSystem Shuriken
So, I have particle system that emit lot of particle(s). I want it after play for few seconds, all particle will come/moved into 1 object position. How can I achieved that?
Do you just want the particles to move in a different direction?
@Nercoe: yes, I want first the particles move randomly, but after a few seconds(particle still live), those particles will be together moved to 1 position. I want create effect like some magic spell, where shine-particles after few seconds will be moved to enemy position.
Answer by Legend of Hibiki · Jan 28, 2013 at 11:43 AM
It's more easy if you create a prefab.
and use this code in your player
var shuriken : GameObject;
var throwShuriken = false;
var throwShurikenTime : float = 0;
var throwShurikenNumber : float = 0;
function Update()
///key pressed {throwShuriken=true;}
if(throwShuriken){
throwShurikenTime + = Time.deltaTime;
if(throwShurikenTime>=0.5){
throwShurikenNumber +=1;
clone = Instantiate(shuriken, transform.position, transform.rotation);
if(throwShurikenNumber>=10){
throwShuriken=false;
}
}
}
}
Answer by Legend of Hibiki · Jan 28, 2013 at 11:43 AM
to follow you create a script and attach to your shuriken
i'm portuguese "rotacao" it's max rotation that your shuriken can do; and "tempo" is the maximo time that shurikens are on the field;
var target : Transform; var tempo : float =0;
function Update(){ tempo+=Time.deltaTime;
transform.Translate(Vector3.forward*Time.deltaTime*speed);
if(rotacao>=-40 && rotacao<=40){
var relativePoint = transform.InverseTransformPoint(target.transform.position);
if (relativePoint.x < 0.0){
transform.Rotate(0, rotacaospeed*-1 , 0);
rotacao-=rotacaospeed;
}else if (relativePoint.x > 0.0) {
transform.Rotate(0, rotacaospeed , 0);
rotacao+=rotacaospeed;
}else{
transform.Rotate(0,0,0);
}
}
if(tempo>=2){
Destroy(gameObject);
}
}