我想要统一实例化的 gameobj 的值,该值位于其他脚本中的光子网络上,以便我的相机可以跟随玩家

发布于 2025-01-12 00:43:07 字数 801 浏览 3 评论 0原文

 public class playeri : MonoBehaviourPunCallbacks
 {
public GameObject[] playerprefab = new GameObject[1];
public Transform[] spawnpoints; //THIS IS THE SPAWN POINTS FROM WEHRE THE player comes out 



void Start()
{

    // PhotonNetwork.LoadLevel(1);
   //followplayer a = GetComponent<followplayer>();
    
            print("hello");
    int randomnumber = Random.Range(0, spawnpoints.Length);
    Transform spawnpoint = spawnpoints[randomnumber];
    int random = Random.Range(0, playerprefab.Length);
    GameObject playertosp = playerprefab[random];
    

          
  GameObject target = PhotonNetwork.Instantiate(playertosp.name, spawnpoint.position, 
 Quaternion.identity);
     
    
}

我遇到的问题是,

我希望我的相机跟随在光子上实例化的玩家,所以有人可以告诉我我该怎么做吗?我很困惑,所以请告诉我这一点

 public class playeri : MonoBehaviourPunCallbacks
 {
public GameObject[] playerprefab = new GameObject[1];
public Transform[] spawnpoints; //THIS IS THE SPAWN POINTS FROM WEHRE THE player comes out 



void Start()
{

    // PhotonNetwork.LoadLevel(1);
   //followplayer a = GetComponent<followplayer>();
    
            print("hello");
    int randomnumber = Random.Range(0, spawnpoints.Length);
    Transform spawnpoint = spawnpoints[randomnumber];
    int random = Random.Range(0, playerprefab.Length);
    GameObject playertosp = playerprefab[random];
    

          
  GameObject target = PhotonNetwork.Instantiate(playertosp.name, spawnpoint.position, 
 Quaternion.identity);
     
    
}

}

what issue I have is that I want my camera to follow the player that is instantiate over the photon so can anyone tell me how can I do this I am very confused so tell me about this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文