【问题标题】:Photon Networking Instantiate Error (Unity3d)光子网络实例化错误(Unity3d)
【发布时间】:2012-11-02 00:57:17
【问题描述】:

好的,所以我正在 Unity 中制作在线 FPS,我正在编写 Photon Networking 脚本来连接和生成播放器,但我不断收到以下两个错误:

Assets/Resources/GameManager.cs(64,23): error CS1502: The best overloaded method match for `PhotonNetwork.Instantiate(string, UnityEngine.Vector3, UnityEngine.Quaternion, int)' has some invalid arguments

Assets/Resources/GameManager.cs(64,23): error CS1503: Argument `#1' cannot convert `UnityEngine.Transform' expression to type `string'

这是我的代码中的错误:

    // When Connected [Photon Callback]
void OnJoinedRoom()
{
    PhotonNetwork.Instantiate(playerPrefab, transform.position, Quaternion.identity, 0);
}

//In Game: Disconnect from room.
void InGameGUI()
{
    if (GUILayout.Button("Leave Game"))
        PhotonNetwork.LeaveRoom();
}

}

我确实在顶部引用了 Transform:

public Transform playerPrefab;

关于我做错了什么以及如何解决它的任何想法。请帮忙!

【问题讨论】:

    标签: networking unity3d instantiation multiplayer frame-rate


    【解决方案1】:

    PhotonNetwork.Instantiate 需要 string,而不是 Transform 对象作为它的第一个参数。 (我相信这是不久前从Transform 对象更改的)。只需命名您要实例化的预制件(必须在Resources 文件夹中)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-16
      • 1970-01-01
      • 2015-06-12
      • 1970-01-01
      • 1970-01-01
      • 2018-02-02
      • 2015-05-11
      相关资源
      最近更新 更多