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;

        }
    }

本文标签: