- Home /
PhotonNetwork Scripted Spawn player
Hey guys i am new to unity answers site :) And i have think a while before i do that post and tryed alot to get it working but i could not :( I started a FPS projekt working in solo without internet access and with internet and with other players using photon It got mp and zm game types means you + friends or matchmaked peps Vs. Zombies Multiplayer is vs bits witg logics... or vs. Other players.
All work fine except thois one hige problem i ran into. Now ill aks for some help.
If i load up the lobby in my menu (ZMUI_LOBBY) It gets all players from the lobby even if solo.. All fine After the host starts the game it counting down also this is working over the serealize function... All fine. :) Now in the loading screen after loading the level it sets a custom propertie to true that the player losded the level and waits for the others to finish losding All works fine bit now if all players are ready the courentine goes on and beforebi started implementing unity i tryed to make the game without prefabs... and here i have the problem. I spawn my player over scripts
Every player including me starts the loadingscreenfunction. Then its waiting on all clients for the players to be all ready (level loaded) Now then the code comes where it spawns the playercode is
gentity_t ent = G_Spawn() gclient_t cli = (add new gclient script to ent gameobject)
Now the gspawn functions is creating a new gameobject add a genrity component and sets vsriables to it like what type it is.... and adds it to the menu.entities... Now not even the gameobject is created on a other client. Only always the player self for you is visible. The others see only themself and no gameobjwct is created ( i looked into the inspector) Now how can i spawn it over network without using prefabs because my player gets it stuff all by script like seting up weapons( models get spawned and set the parent of the cameras(game objects by script...)
Obly on the view of the client its the player visible but the other player in the room is not visible. The funxtion is not called twice nothing.
this get called if the loading screen ends and spawns the player [PunRPC] public gclient_t G_Spawn_Zombie_Client(int viewID) {...}
in it it checks if solo...
if(!CL.isSolo)
{
cli.photonView = cli.gameObject.AddComponent<PhotonView>();
cli.photonView.ownerId = viewID;
cli.photonView.synchronization = ViewSynchronization.Unreliable;
cli.photonView.ObservedComponents = new List<Component>();
cli.photonView.ObservedComponents.Add(cli);
cli.photonView.ObservedComponents.Add(this);
}
cli is here the gclient that get added in a line above.
and i call this function like that
int viewID = PhotonNetwork.AllocateViewID();
mainPhotonView.RPC("G_Spawn_Zombie_Client", PhotonTargets.OthersBuffered, viewID);
client = G_Spawn_Zombie_Client(viewID);
So i realy need help.
Thanks in advance :)
(Made with my phone)
Your answer
Follow this Question
Related Questions
How to connect to our own dedicated server using photon networking in unity?(Self-hosted) 0 Answers
Photon Network instantiate problem when Master changes 0 Answers
Problem with PhotonView.RPC 1 Answer
This is giving an error for the other client and cannot hit other client. 1 Answer
Custom Properties, Unity, Object refence not set to an instance of an object 0 Answers