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 /
This question was closed Jul 06, 2015 at 11:02 AM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by RZ0895 · Jun 29, 2015 at 10:46 AM · unity 5networkingspawning

New Unity 5.1 Networking :- Spawning is not synchronized!!!!

Hello, I am a junior undergraduate student and I am new to UNITY and Game development.

I have problem spawning players in my game. I am using new unity Networking. I have set two empty gameObjects as StartPosition(New Network Components) in my Scene. When i connect either from client or server the local player gets spawned at 1st SpawnPosition and the other at 2nd SpawnPosition (although they appear correct in game). But it's actually not like what i have expected. It appears that in both game application myplayer is at 1st SpawnPosition and the other at 2nd SpawnPosition. i.e spawning is not synchronized. Please help me through it. Thanks in advance.

here is what i am trying to achieve for my two player game...

 public class Spawner : NetworkManager {
      public Transform[] spawnSpots;
      public override void OnServerAddPlayer (NetworkConnection conn, short playerControllerID)
      {
  
          if(isServer)//isServer doesn't exist
          {
              GameObject player = (GameObject)Instantiate(base.playerPrefab,spawnSpots[0].position,spawnSpots[0].rotation);
              NetworkServer.AddPlayerForConnection(conn,player,playerControllerID);
          }
          else if(isClient)//isClient doesn't exist
          {
              GameObject player = (GameObject)Instantiate(base.playerPrefab,spawnSpots[1].position,spawnSpots[1].rotation);
              NetworkServer.AddPlayerForConnection(conn,player,playerControllerID);
          }
      }
 }

Comment
Add comment · Show 4
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 CasperK · Jun 29, 2015 at 12:18 PM 0
Share

How do you set isServer and isClient?

avatar image RZ0895 · Jun 29, 2015 at 05:34 PM 0
Share

I am not not using this code it is just like a pseudocode of what i want to achieve. In fact isServer and isClient doesn't exist in this scope.

I am trying to making a game in which two players spawn facing each other somewhat like in a capture the flag type of games. In the server game application(also client,let's call it "client1") 1st player joins and spawns at 1st spawn point. The second player("client2") joins and spawns in 2nd spawn point. But in the Second player's Application window("client2"), 2nd player spawns at 1st spawn point(here i want to spawn at 2nd spawn point so that it stays synchronized with the server) and 1st player(server player) spawn at 2nd spawn point(which should be at 1st spawn point).

i have marked the two spawn points as "Network Start position"(The component that comes in the new unity 5.1 networking). And i am using "round robin" as "player spawn method"($$anonymous$$ethod in new unity 5.1 networking component Network$$anonymous$$anager).

I think this explains the problem better.

avatar image CasperK · Jun 29, 2015 at 10:00 PM 0
Share

From the code you posted I cant see why it won't be synchronised.

As long is IsServer and IsClient is set correctly on connecting and spawnSpots[] is not set randomly, then your way should be working.

To make it random you could make the server decide what spot to spawn on, then sent the other spot to the client to spawn on.

avatar image RZ0895 · Jun 30, 2015 at 03:56 AM 0
Share

Yeah Casper$$anonymous$$, it makes sense here, but its not the correct way to solve it. isServer and isClient doesn't exist in the class scope.

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by RZ0895 · Jul 01, 2015 at 06:49 AM

Sorry guyz for trouble, after a lot of debugging and study found out my noob mistake.

i was finding GameObject with name and turning his camera and controller on. But it always found the server player first and turned his controller and camera on. So it appeared that they spawned like that.

Comment
Add comment · 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
0

Answer by psistalk · Jun 30, 2015 at 11:09 AM

if your using UNET try this

using UnityEngine.Networking;

public class Spawner : NetworkBehaviour {

NetworkBehaviour derives from Monobehavior

then

if(isLocalPlayer){}

if(isServer){}

Comment
Add comment · Show 2 · 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 RZ0895 · Jun 30, 2015 at 11:26 AM 0
Share

isLocalPlayer is not assigned till the new Player(the prefab we set in network manager in UNET) is spawned. So, can't get it to work.

avatar image ajaybhojani · Jan 01, 2016 at 06:09 AM 0
Share

I have spawned player successfully :) But trying to display own player on screen centre position and other joined player should be available either left or right. Each player can see his position on center in his app. Is it possible ? I am using photonview.is$$anonymous$$e method. But not succeed.

please help

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

UNET 5.2: How do you use NetworkServer.SpawnWithClientAuthority()? 1 Answer

Question about Unet and spawning 0 Answers

Change player object - UNET 1 Answer

Why does my server show different position for my client? 1 Answer

Transform.parent not set on clients UNET 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