Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Fadi · Apr 23, 2014 at 01:47 PM · networkserverclient

Network , new player can't see the old players ?

Hi ...

Im trying to make a network game.

but I've one problem :

I created a new game on sever side , then one of the clients join to that game , after that I started the game ... in this case every things OK

but when Create and Start game on server before any clients join to game .. in this case when client connect to server , the server can see him , but client can't see the server (" new player can't see the old players that already connected " )

any idea ?

thanks

Comment
Add comment · Show 2
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
avatar image Fadi · Apr 23, 2014 at 03:08 PM 0
Share

how can i make new Network.Instantiate for all old players that already in game, and these clone show just in the last player joined

avatar image Fadi · Apr 23, 2014 at 03:45 PM 0
Share

this one for create the player when level loaded

 function CreatePlayer ()
 {
 var play : GameObject = Network.Instantiate(Player,Vector3(0,1,0), Quaternion.identity,0) as GameObject;
 }

when new player connect to server will check if the game started or not

 function OnPlayerConnected(networkPlayer : NetworkPlayer )
 {
 if ( $$anonymous$$anager_Server.StartGame )
 networkView.RPC("Server_Started_Game",RPC$$anonymous$$ode.Others,$$anonymous$$anager_Server.$$anonymous$$apName);
 }

if yes the client will start the game and call the "CreatePlayer" function , so the server will see him . but this new client doesn't see the serever player .

Note : if the client connect to server and the server doesn't started the game yet, will add the client to the list , after press on "Start game" on server , the game will start in both Client/Server , and client and server will see each others _

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Minchuilla · Apr 23, 2014 at 02:58 PM

Assuming that by "players" you mean GameObjects of other players:

Be sure that you use Network.Instantiate() this will create a copy for each player

Docs here.

When destroying GameObjects use the code in my answer in this post.

Feel free to ask more questions.

Michuilla

Comment
Add comment · Show 6 · Share
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
avatar image Fadi · Apr 23, 2014 at 03:04 PM 0
Share

thank u for answering me ...

I used "Network.Instantiate()" because all the old players , see the new one , but the last one joined to the game , doesn't see any players ..

avatar image Minchuilla · Apr 23, 2014 at 03:08 PM 0
Share

that seems strange, are you sure you arent using any groups when using Network.Instantiate();

could you give me a code sample of just a few lines please

avatar image Minchuilla · Apr 23, 2014 at 03:11 PM 0
Share

Actually, Network.Instantiate is an RPC that is buffered so that every user that joins gets the instantiation call, so I don't know why it's not working

avatar image Fadi · Apr 23, 2014 at 03:30 PM 0
Share

this one for create the player when level loaded

 function CreatePlayer ()
 {
 var play : GameObject = Network.Instantiate(Player,Vector3(0,1,0), Quaternion.identity,0) as GameObject;
 }

when new player connect to server will check if the game started or not

 function OnPlayerConnected(networkPlayer : NetworkPlayer )
 {
 if ( $$anonymous$$anager_Server.StartGame )
 networkView.RPC("Server_Started_Game",RPC$$anonymous$$ode.Others,$$anonymous$$anager_Server.$$anonymous$$apName);
 }

if yes the client will start the game and call the "CreatePlayer" function , so the server will see him . but this new client doesn't see the serever player .

Note : if the client connect to server and the server doesn't started the game yet, will add the client to the list , after press on "Start game" on server , the game will start in both Client/Server , and client and server will see each others _

avatar image Minchuilla · Apr 23, 2014 at 03:48 PM 0
Share

This seems fine except that I don't quite understand why you call "Server_Started_Game" to "RPC$$anonymous$$ode.Others"

What I would do Ins$$anonymous$$d is this:

When the server starts the game

 //in server
 function OnGameStarted()
 {
    networkView.RPC("CreatePlayer", RPC$$anonymous$$ode.AllBuffered, mapName);
 }

notice that RPC$$anonymous$$ode is buffered

This code then doesn't require the function OnPlayerConnected

Hopefully the Instantiation will work correctly then

Show more comments

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

21 People are following this question.

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

Related Questions

Smooth network communication like Unity remote 1 Answer

NetworkView Component state update 2 Answers

Pass an array from server to clients 0 Answers

Network. Send to client server info. 0 Answers

"Trying to send command for object without authority" warning but the object is the localPlayer 1 Answer


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