以下是我生成,移动和摧毁障碍的代码:
#pragma strict
var speed:float=1.5f;
var obstart:Transform;
var obstack:GameObject;
var pos:Transform;
var i:int=0;
function Start () {
Invoke("Obs",4.0f);
}
function Update () {}
function Obs(){
pos=obstart;
pos.position = new Vector3(
obstart.position.x,
obstart.position.y,
obstart.position.z + (i*5)
);
i=i+1;
obstack=Instantiate(obstack,pos,Quaternion.identity);
obstack.rigidbody.velocity=Vector3.left*speed;
Destroy(obstack,10.0f);
Invoke("Obs",4.0f);
}
我正面临一个错误:
BCE0023:找不到适当版本的'UnityEngine.Object.Instantiate'参数列表'(UnityEngine.GameObject,UnityEngine.Transform,UnityEngine.Quaternion)'。
答案 0 :(得分:0)
Instantiate
第二个参数是position
而非transform
obstack=Instantiate(obstack,pos.position,Quaternion.identity);