instantiate players in canvas PUN2 Unity
Hi everyone. I create matchmaking with PUN2 in Unity2d. I have a room for two players, which I spawn across each other. For players I have the prefab. In my case, I have a problem, because I need to instantiate players in canvas. For local player I use transform.setParen - it works. But for the connected player I don’t know how to do that. There is my code...
private PhotonView myPhotonView;
private GameObject player;
[SerializeField] GameObject playerPref;
[SerializeField] Transform canvas;
void Start()
{
myPhotonView = GetComponent<PhotonView>();
if (myPhotonView.IsMine)
{
player = PhotonNetwork.Instantiate(playerPref.name, Vector3.zero, Quaternion.identity);
player.transform.SetParent(canvas);
player.GetComponent<SpriteRenderer>().color = Color.blue;
}
}
Best Answer
-
Hey guy, a static camera in the scene can help you in that maybe:
"camera player 1" will be at same position and size of "camera player 2"
(Then if your player are in top left of camera, the second player will see it top left, because is the same worldposition )
Camera player 1 and camera player 2= The scene camera
0
Answers
-
Hey guy, a static camera in the scene can help you in that maybe:
"camera player 1" will be at same position and size of "camera player 2"
(Then if your player are in top left of camera, the second player will see it top left, because is the same worldposition )
Camera player 1 and camera player 2= The scene camera
0