- Home /
PhotonNetwork.Instantiate 2 problems.
I have these two problems with PhotonNetwork.Instantiate...
1) Whenever the player gets instatiated it wont react to collision and will constantly fall (Uses 'Character Controller') untill the player provides input which moves the character ( like 'a' or 'd' and the char gets to collide and function correctly).
2) Clients can only see other clients which instantiated AFTER THEY joined. It goes like this:
Player1 has joined.
Player2 has joined.
Player1 can see player2, player2 cant see player1.
Player3 has joined.
player2 can see player3, player1 can see player2 & player3, player3 sees no one.
Please, help me!
I am still stuck... Tried to follow the tutorial but everything should make sense..
Have you tried the Angry Bots Photon Demo? It has working multiplayer instantiation. I modified it and am using it currently and it works as you want. The Code - Game$$anonymous$$anager.cs script instantiates the playerPrefab you want and it has a movement controller and camera controls and a collider capsule.
Try stripping it down like this and modifying your code to run on top of it: http://unitycoder.com/blog/2012/12/15/photon-networking-multiplayer-game/
Answer by Jamster · Dec 25, 2012 at 05:17 PM
Remember that when using a Character controller you need to manage the gravity yourself, meaning you need to only move the y axis down when you aren't grounded. This might not solve your problem but I usually forget.
As for the second one I've had this problem with unity Networking but not with Photon, annoyingly I didn't solve it... All I can reccomend is to have a look at the Marco Polo tutorial for the instantiating routine then compare it to yours (even copy and paste bits across). My photon game was built around the Marco Polo tutorial so I never had to bother with the instantiating code, I just adapted the script for my use.
Jamster, the character wont have these issues of collision in case of a regular instatiate... Just photons.. I also followed marcopolos tutorial to make this one... I tried to update the photon but it didnt help my problem either.. :P
The problem you describe does not happen when you just join a room and instantiate GOs. It must be something you do beyond that. To debug, you could disable actions you do one by one and use simple prefabs with just a photonView on them.
Are you loading a scene when joining a room? In that case, the load might happen after (!) the remote Instantiate calls were done. The scene they were executed for is destroyed and the fresh instantiated objects are gone before you see them.
I can't help with the character controller / falling issue, sorry. $$anonymous$$aybe the problem is that multiple controllers are active and fight for control?
Answer by zotey · Jan 08, 2014 at 01:11 PM
Make sure you send a buffered rpc that the first player is spawned
Answer by Bons · May 30, 2014 at 11:21 AM
You must be having lobby and room in 1 scene and game in another scene.
You must load scene by
PhotonNetwork.LoadLeve("Scene Name");