早教吧作业答案频道 -->数学-->
unity3dC#关于随机点产生随机物体问题.voidStart(){p1=newVector3(-2.5f,0.8f,-0.01f);p2=newVector3(-2.5f,0.4f,-0.01f);p3=newVector3(-2.5f,-0f,-0.01f);p4=newVector3(-2.5f,-0.4f,-0.01f);p5=newVector3(-2.5f,-0.8f,-0.01f
题目详情
unity3d C# 关于随机点产生随机物体问题.
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)产生.
而且物体是翻转的.
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)产生.
而且物体是翻转的.
▼优质解答
答案和解析
为什么你提问了两个同样的问题...难道是为了再采纳我一次?- -!
看了 unity3dC#关于随机点...的网友还看了以下:
选出与所给单词括号部分的读音相同的一项.1:cr(y).A:tr(y);B:cit(y);C:(y 2020-05-13 …
大家看看这个lingo程序哪里错了啊····谢谢各位model:title first steps 2020-05-13 …
1.设有变量定义inti,j;与表达式i==0&&j==0等价的表达式是:()(A)i==j(B) 2020-05-14 …
MATLAB设计Jacobi迭代法运行错误,设计函数:function [x,k]=jacobi_ 2020-05-16 …
——Tom,you are 10 minutes late,please don't be lat 2020-05-16 …
选择元音字母在单词中发音不同的一项.1;A:h(a)nd;B:f(a)ce;C:(a)pple.2 2020-06-17 …
unity3dC#关于随机点产生随机物体问题.voidStart(){p1=newVector3( 2020-07-21 …
(斐波那契数列)谁能解释一下这个程序中的“c[i]:=c[i]+a[i]+b[i];varn,i, 2020-07-23 …
电容电压与电流的相量式的问题,跟虚数i有关书中相量式U=1/(iωC)*I=-i*1/(ωC)*I 2020-07-30 …
问个C语言,不明白啊题目:字符数组采用单个字符(%c)方式输入,并将它逆序输出。#include"s 2020-12-02 …