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 Ibzy · Dec 19, 2014 at 12:24 AM · networkingloadlevel

Networking LoadLevel - player connect

I've got a lot of my networking platform in place at the moment, but when setting up my NPC/Enemy to take syncd damage (by adding a networkview component and RPC'ing the damage as per the player script) I have noticed that the enemy is reloaded for player 2. This is indicated by damage being dealt by player 1 before player 2 joins, and the enemy being at full health when player 2 joins - damage inflicted after this affects both.

I think this is because the level is being loaded for player 2 rather than "joined" - how do I have player 2 "the client" join the scene created by player 1 "the server"?

Side question: is my approach to NPCs/Enemies the correct one?

Cheers

Edit: As per comment:

     void OnConnectedToServer(){
         SpawnPlayer ();
     }
 
     private void SpawnPlayer(){
         Application.LoadLevel (1);
         GameObject player =  Network.Instantiate (playerPrefab, new Vector3 (0, 0.2f, 0), Quaternion.identity, 0) as GameObject;
         player.GetComponent<Player> ().PlayerName = playerName;
     }

This is also called in OnServerInitialized();

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Ibzy · Jul 02, 2015 at 06:20 PM

With the new UNET functionality I can now simply spawn the enemy once as the server, and then new players just see them. Simple :)

Comment
Add comment · Show 1 · 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 FirePlantGames · Jul 03, 2015 at 01:32 AM 0
Share

You know responding on dead threads is depreciated right? Along with accepting your own answer. (That's a little more forgivable :P )

However this should help some other people. So, answer is appreciated. $$anonymous$$aking my comment rather redundant.

avatar image
0

Answer by FirePlantGames · Dec 19, 2014 at 02:28 AM

Use RPCMode.AllBuffered this adds the RPC to the buffer(the buffer is loaded when the player joins the server)

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 Ibzy · Dec 19, 2014 at 08:33 AM 0
Share

I already have it set to AllBuffered, its as though the whole scene, including the enemy, is recreated for player 2 so its a mew enemy which receives both RPCs?

avatar image FirePlantGames · Dec 19, 2014 at 04:04 PM 0
Share

Oh, I see what you mean now, yeah, state synchronization is a real pain. It's a problem with networkView id's, could you share you instantiation code?

avatar image Ibzy · Dec 19, 2014 at 07:32 PM 0
Share

Only instantiation code is for the Player (added above) - I tried one for the enemy and a new one got instantiated as player 2 joined. This use a separate "level master" script to Network.instantiate() on Start(). I'm thinking I need to use OnServerInitialized(), but I want this game to consist of many scenes not necessarily inhabited by all players at the same time, rather than it all on one scene?

avatar image FirePlantGames · Dec 20, 2014 at 04:38 PM 0
Share

Okay, so what happens is this; 1. You connect and Everything From the server is loaded into the current Scene. 2. You then load a completely new scene thusly removing all of the networks objects and leaving them in the old scene. 3. Solution: I'm working on it :/ I will come up with one, and I already have a concept down, I just have to test it.

avatar image Ibzy · Dec 21, 2014 at 03:02 PM 0
Share

That's exactly what's happening, except the object in scene 1 is still there for player 1 and a new version is created for player 2 but they are then linked. Its definitely a matter of having my players "join" I just cant see any reference to it anywhere.

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

28 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Client not loading into the same scene as host 0 Answers

Networking Help Needed 0 Answers

Networking - 2 Scenes where one i selection and other actual game 2 Answers

How to load online level 2 Answers

Unity networking tutorial? 6 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