unity3d关于随机点产生物体的问题。
publicList<GameObject>_yu;publicList<Vector3>_point;voidStart(){p1=newVector3(-2.5f,0...
public List<GameObject>_yu;
public List<Vector3>_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)产生的问题,而且物体会翻转。
求帮助。
谢谢。 展开
public List<Vector3>_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)产生的问题,而且物体会翻转。
求帮助。
谢谢。 展开
1个回答
展开全部
翻转是因为你都用了一个旋转度Quaternion.identity,这个地方要改为你需要的角度
至于位置_point[Random.Range(0,5)],你在初始化之前输出一下,看为什么是000
至于位置_point[Random.Range(0,5)],你在初始化之前输出一下,看为什么是000
追问
Quaternion.identity
这个地方怎么改需要的角度?
追答
这是个四元数,代表的是transform.rotation,如果你不知道你想要的角度是多少Quaternion,就先调好角度,找个代码输出一下(transform.rotation),在控制台复制输出的四元数,再写入代码中,采纳吧...
光点科技
2023-08-15 广告
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询