Hello, I'm currently creating simple multiplayer first person shooter using PhotonNetwork engine, but I got crushed into the problem.
The problem I have is this:
I spawn Player1 using Manager by (PhotonNetwork.Instantiate)
I spawn Player2 using Manager by (PhotonNetwork.Instantiate)
but the problem is player1 can see player2, but player2 cannot see player1. I figured it out that it's not "buffered" Is there a way to solve this problem?
PhotonNetwork.Instatiate(...) is buffered, so there shouldn't be a problem with that. Do you use the group parameter of the function (the last one) with any value else than 0 in one of these cases? In this case you need to set sending and receiving enabled for all clients.
My group parameter is "0" Here is my piece of code where I instantiate the object:
player = (GameObject)PhotonNetwork.Instantiate("myPlayer", Vector3.zero, Quaternion.identity, 0);
I thought I did solved the problem, but I didn't. I'm still having this problem. Please someone help me. The thing is whenever I try the photonnetwork.Instantiate in my "test project", and it worked. I think there is something with my script...
player = (GameObject)PhotonNetwork.Instantiate("myPlayerClassInit", new Vector3(0, 10, 0), Quaternion.identity, 0);
player.GetComponent<LobbyPlayerSetup>().enabled = true;
This is litterly what I have in void Start() method... Please help me
You can try moving the Instantiation call from the Start() function to a OnJoinedRoom() callback. This makes sure that the client has definitely joined the room.
Can you tell us what happens in LobbyPlayerSetup script / component? I am also a bit confused about this name, because there are differences about the lobby and the room.
Ok, in LobbyPlayerSetup, it's where I change the name of an object that I instantiated. I used simple GetComponent().RPC("ChangeName", PhotonTargets.AllBuffered, username); and there is no problem with it.
I'll explain you the scene. So basically, I''m trying to make a class selection scene. When ever the player gets into the room, I instantiate an object to the class selection scene, and in that object, there are some variables such as "current Class" or which team i'm belonging. And I made sure that instantiation call is called AFTER when player joined room. I checked using simple "ConnectionStateDetailed", and I even gave a little bit of delay using StartCorutine, and tried "OnJoinedRoom".
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
108 People are following this question.
Proper way to instantiate projectile in PUN
[Help] Problem instantiatedObjects Chang Scene from Lobby(Photon)
Photon Network Instantiate Objects over Network
How to assign Photon Instantiated object's public functions to a gui button events such as OnPointerEnter
Using RPC to Instantiate