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 MCoburn · Sep 20, 2014 at 10:36 AM · networkingserversclients

Network Level Loading: Best practice for getting hosts' current level name?

Sorry if this is too long - tl;dr version at the bottom of all this!

I'm working on a shooter that has two types of server modes - a dedicated "headless" mode and a "play and host" mode which is like today's shooters, where you are able to play while various server player scripts handle the I/O load.

At the moment, I have a script, used in the gameMenu scene that handles the main menu. I also have a class that is called "NetworkLevelLoader" to help ease the pain of network level loading (it will automatically go through the process to stop the message queue, etc etc, while the level loads).

The main menu checks all the input, etc and then starts a connection to the server once a button is clicked. At the moment, the server and client both talk to each other correctly when I manually load the level explicitly (apart from some Scene NetView ID mismatches and warnings, but since I anticipate more than 1 map in the game, I need a method that reports back to the new client what level is currently being played, which the client will then load and sync up.

The current implementation is this:

 // server side logic script on a gameObject with a networkView. 
 // This script only fires if it's the server (aka connected clients don't have a say
 // on what level to load)
 
 [RPC]
 void clientLoadLevel(string levelName) {
 NetworkLevelLoader.Instance.Load(levelName);
 }
 
 void OnPlayerConnected(NetworkPlayer player) {
 networkView.RPC("clientLoadLevel", player, Application.loadedLevelName);
 }

That code is not 1:1 to the actual code in the project as the dev machine is at the office, but I guess you can get the idea. In fact, that code might even work. I dunno.

The main menu scene has a gameobject that has a script which contains the same "clientLoadLevel" function in it so that it can trigger the level load. However, when I get the server to relay the level name to the client, it throws a error (I forget the exact error message, but something like NetworkView inconsistent), or the call just falls on deaf ears, leaving the client stuck in limbo.

tl;dr version: Could someone please shine some light on how to tell clients on connecting to a server that's already in-game what level to load?

Thanks for the help, I appreciate it. It must be something I'm overlooking.

Comment
Add comment · Show 1
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 MCoburn · Sep 21, 2014 at 01:16 AM 0
Share

Okay, after some more tinkering, I can confirm that I am getting the RPC. However, what does this mean?

View ID SceneID: 2 Level Prefix: 0 not found during lookup. Strange behaviour may occur Could't invoke RPC function 'clientLoadLevel' because the networkView 'SceneID: 2 Level Prefix: 0' doesn't exist

The client is then stuck at the "Starting the game" screen that pops up.

The main menu is actually scene 2 in the level build dialog... but why am I getting this? Scene 2 has a gameobject that handles the menu and THAT has a NetworkView attached.

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

2 People are following this question.

avatar image avatar image

Related Questions

Network servers are overlapping in the multiplayer menu 0 Answers

How can I send RPC from one client to another client directly in multiplayer game? 0 Answers

Unet Networking: having two clients in the editor instead of building for standalone? 0 Answers

Client shooting is lagging 0 Answers

Send and recieve variables to all clients using smartfox 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