Unity3d Unity 3d如何在特定位置实例化对象

Unity3d Unity 3d如何在特定位置实例化对象,unity3d,Unity3d,使用UnityEngine; 使用系统集合 公共类playSound:单一行为{ private bool destructionHasBegun = false; public Transform BlueKey; private void OnTriggerEnter() { audio.Play (); destructionHasBegun = true; } private void Update() { if(destructionHasBegun)

使用UnityEngine; 使用系统集合

公共类playSound:单一行为{

private bool destructionHasBegun = false;
public Transform BlueKey;


private void OnTriggerEnter()
{
    audio.Play ();
    destructionHasBegun = true;
}

private void Update()
{
    if(destructionHasBegun)
    {
        DestroyWhenSoundComplete();
    }
}

private void DestroyWhenSoundComplete()
{
    if(!audio.isPlaying)
    {
        Destroy(gameObject);
        GameObject textObject = (GameObject)Instantiate(Resources.Load("BlueKey")); 





    }
}
}

我试图在一个特定的位置实例化bluekey预置,我该怎么做?提前感谢

根据,您可以将Vector3世界空间位置作为第二个参数传入

您还需要传入四元数作为其初始旋转的第三个参数;相当于没有旋转

Vector3 newPosition=新矢量30,0,0; 四元数newRotation=四元数.identity; GameObject textObject=GameObjectInstantiateResources.LoadBlueKey、newPosition、newRotation;
我收到这个错误“UnityEngine.Vector3”是一个“类型”,但它的使用方式类似于“变量”CS0118程序集-CSharp@user3482470啊,抱歉,忘了在Vector3构造函数前面写新的。请查看更新的代码。