unity3d C# 关于随机点产生随机物体问题。

voidStart(){p1=newVector3(-2.5f,0.8f,-0.01f);p2=newVector3(-2.5f,0.4f,-0.01f);p3=newV... void Start () {
p1 = new Vector3 (-2.5f,0.8f,-0.01f);
p2 = new Vector3 (-2.5f,0.4f,-0.01f);
p3 = new Vector3 (-2.5f,-0f,-0.01f);
p4 = new Vector3 (-2.5f,-0.4f,-0.01f);
p5 = new Vector3 (-2.5f,-0.8f,-0.01f);
p6 = new Vector3 (2.5f,0.8f,-0.01f);
p7 = new Vector3 (2.5f,0.4f,-0.01f);
p8 = new Vector3 (2.5f,0f,-0.01f);
p9 = new Vector3 (2.5f,-0.4f,-0.01f);
p10 = new Vector3 (2.5f,-0.8f,-0.01f);
}
void Update () {
i = Random.Range(1,6);
AddDians();
CreateFish();
CreateFish2();
CreateFish3();
CreateFish4();
CreateFish5();
void CreateFish(){
if(i == 1){
GameObject yu = (GameObject) Instantiate(_yu[Random.Range(0,5)], _point[Random.Range(0,5)], Quaternion.identity);
GameObject yu2 = (GameObject)Instantiate(_yu[Random.Range(6,_yu.Count)], _point[Random.Range(6,_point.Count)], Quaternion.identity);
iTween.MoveTo(yu,iTween.Hash("x",2.5,"time",4,"EaseType","Linear"));
iTween.MoveTo(yu2,iTween.Hash("x",-2.5,"time",4,"EaseType","Linear"));
}
}
void CreateFish2(){
if(i == 2){
GameObject yu = (GameObject)Instantiate(_yu[Random.Range(0,5)], _point[Random.Range(0,5)], Quaternion.identity);
GameObject yu2 = (GameObject)Instantiate(_yu[Random.Range(6,_yu.Count)], _point[Random.Range(6,_point.Count)], Quaternion.identity);
iTween.MoveTo(yu,iTween.Hash("x",2.5,"time",4,"EaseType","Linear"));
iTween.MoveTo(yu2,iTween.Hash("x",-2.5,"time",4,"EaseType","Linear"));
}
}
void CreateFish3(){
if(i == 3){
GameObject yu = (GameObject)Instantiate(_yu[Random.Range(0,5)], _point[Random.Range(0,5)], Quaternion.identity);
GameObject yu2 = (GameObject)Instantiate(_yu[Random.Range(6,_yu.Count)], _point[Random.Range(6,_point.Count)], Quaternion.identity);
iTween.MoveTo(yu,iTween.Hash("x",2.5,"time",4,"EaseType","Linear"));
iTween.MoveTo(yu2,iTween.Hash("x",-2.5,"time",4,"EaseType","Linear"));
curTime = 0;
}
}
void CreateFish4(){
if(i == 4){
GameObject yu = (GameObject)Instantiate(_yu[Random.Range(0,5)], _point[Random.Range(0,5)], Quaternion.identity);
GameObject yu2 = (GameObject)Instantiate(_yu[Random.Range(6,_yu.Count)], _point[Random.Range(6,_point.Count)], Quaternion.identity);
iTween.MoveTo(yu,iTween.Hash("x",2.5,"time",4,"EaseType","Linear"));
iTween.MoveTo(yu2,iTween.Hash("x",-2.5,"time",4,"EaseType","Linear"));
}
}
void CreateFish5(){
if(i == 5){
GameObject yu = (GameObject)Instantiate(_yu[Random.Range(0,5)], _point[Random.Range(0,5)], Quaternion.identity);
GameObject yu2 = (GameObject)Instantiate(_yu[Random.Range(6,_yu.Count)], _point[Random.Range(6,_point.Count)], Quaternion.identity);
iTween.MoveTo(yu,iTween.Hash("x",2.5,"time",4,"EaseType","Linear"));
iTween.MoveTo(yu2,iTween.Hash("x",-2.5,"time",4,"EaseType","Linear"));
}
}
关于创建yu和yu2,是因为物体需要从两个方向过来,所以左面的物体从左面产生,右面的物体从右面产生。
现在的问题是,有一部分的物体从(0,0,0)产生。
而且物体是翻转的。
谢谢大家!
展开
 我来答
正义King
2014-01-26 · TA获得超过2102个赞
知道小有建树答主
回答量:974
采纳率:94%
帮助的人:658万
展开全部
为什么你提问了两个同样的问题...难道是为了再采纳我一次? - -!
追问
不是...那个是化简版的,我怕别人看不懂= =。
追答
那就继续采纳吧...反正就我一个人...- -!
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式