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);
}
}
↧