unity3d关于随机点产生物体的问题.public List_yu;public List_point;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 V
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 05:39:14
unity3d关于随机点产生物体的问题.public List_yu;public List_point;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 V
unity3d关于随机点产生物体的问题.
public List_yu;
public List_point;
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 () {
AddDians();
CreateFish();
}
void AddDian(Vector3 dian){
_point.Add(dian);
}
void AddDians(){
AddDian(p1);
AddDian(p2);
AddDian(p3);
AddDian(p4);
AddDian(p5);
AddDian(p6);
AddDian(p7);
AddDian(p8);
AddDian(p9);
AddDian(p10);
}
void CreateFish(){
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"));
}
会出现物体从(0,0,0)产生的问题,而且物体会翻转.
unity3d关于随机点产生物体的问题.public List_yu;public List_point;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 V
翻转是因为你都用了一个旋转度Quaternion.identity,这个地方要改为你需要的角度
至于位置_point[Random.Range(0,5)],你在初始化之前输出一下,看为什么是000