admin管理员组文章数量:1129019
I am trying to make it so that when one of the two players in my multiplayer game interacts with the trigger on an object both players will be teleported to different locations in the scene based on the translation of spawn points that are put in the level.
Currently when testing whichever player touches the trigger will move to their correct spawn point but the other wont move at all.
The script can be seen below, it is attached to the object which the player touches. The only thing i think may be going on is I am running both instances on the same machine so maybe being tabbed out of one means it won't teleport? I'm really not sure.
private void OnTriggerEnter(Collider other)
{
GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
Debug.Log(players[0].transform.position);
Debug.Log(players[1].transform.position);
if (finalLevel)
{
//show end screen
//disable player input
endScreen.SetActive(true);
players[0].SetActive(false);
players[1].SetActive(false);
}
else
{
//send p1 to p1 start point
//send p2 to p2 start point
players[0].transform.position = PC1StartPoint.transform.position;
players[1].transform.position = PC2StartPoint.transform.position;
}
}
本文标签:
版权声明:本文标题:multiplayer - Unable to teleport both players when a trigger is entered by one player Unity Netcode for GameObjects - Stack Over 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736711582a1948972.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论