Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by michi112 · Feb 27, 2017 at 11:26 PM · c#unity 5photon

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)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges