错误:BCE0023:参数列表没有适当版本的'UnityEngine.Object.Instantiate'(UnityEngine.GameObject,UnityEngine.Transform,Un

时间:2014-09-27 12:19:00

标签: unity3d unityscript

以下是我生成,移动和摧毁障碍的代码:

#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)'。

1 个答案:

答案 0 :(得分:0)

Instantiate第二个参数是position而非transform

 obstack=Instantiate(obstack,pos.position,Quaternion.identity);