Search Unity

[RELEASED] MultiOnline : multiplayer online kit - V3 now available

Discussion in 'Assets and Asset Store' started by VirtuElle, Aug 16, 2013.

  1. ReaList

    ReaList

    Joined:
    Mar 27, 2014
    Posts:
    13
    I do not want players to list, I would like to draw the name of the other players in the game, I want to print.

    I tried to show in the picture,

    $1.png

    I show you in the video?
     
  2. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    To be honest, this error has no sense for me, I don't understand from where it can come.
    If you don't have the problem when you test with many .exe in your own computer, and if the other players can now well join the lobby, I don't really understand why the map's loading doesn't work for them.
    It's as they didn't received the message to load the map. It's a RPC function in MWaitRoom line 423 (LoadGame()), you didn't change it ?
    And did you change anything in the scripts ?
    Does the timer starts for the other players ? Maybe there is a problem in this side, you can try to disable it to see what happen (open WaitRoom scene, clic on WaitRoom object, and in inspector, open menu "Show global parameters" and uncheck the box "Use load time")
     
  3. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    Ok, I understand, you want write the player name below each player.
    For that, you have to know the position of the player, and write his name below his gameObject.
    I don't know what is your approach, but for example, you could use the playerList which is in MNetwork, browse the player list, search each player from his NetworkView id (it's "gameId" in the playerlist), and write his name below each player.
     
  4. adamz

    adamz

    Joined:
    Jul 18, 2007
    Posts:
    957
    Is it possible to setup an authoritative server with your asset? Will this also work seamless with a web-player; say someone comes to my site to play?

    Thanks.
     
  5. TheDevGuy

    TheDevGuy

    Joined:
    Mar 3, 2014
    Posts:
    78
    That fixed all issues i had with connection! Thank you.

    Another small thing is that when the other player is in the default maps with me his move speed is about 15x faster than mine as the default cube players.

    And where can i find the GUI information for the MENU and WAIT ROOM? Is it a single GUISkin or can i assign single textures to each button, as this would be ideal.
     
    Last edited: Apr 23, 2014
  6. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    Great !

    I have already seen this problem, that's something which come from the "Graphics quality" which is selected when you start the .exe file.
    That's possible that the default Graphics quality in not the same as in your editor. If you start the game with graphics quality "simple", your cubes should have a normal movement.
    You can set/delete the graphics qualitiy levels directly from Unity in Edit / Project settings / Quality (the menu will open in the inspector).

    There is currently no GUISkin for that, that's something I have corrected in next version.
    But you can easily add one yourself, example, for adding a GUI skin for MMenu:

    In MMenu:
    Put this in the variables declarations (line 8 for example)
    Code (csharp):
    1. public GUISkin customSkin;
    Put this in the OnGUI() function (line 167)
    Code (csharp):
    1. void OnGUI(){      
    2.     GUI.skin = customSkin;
    3.     // ...
    And in MMenuEditor (which is in Editor folder), put this line somewhere you want in OnInspectorGUI() function:
    (For example, if you want to seen it in "Global parameters" menu, put it line 20)
    Code (csharp):
    1. edit.customSkin = EditorGUILayout.ObjectField(edit.customSkin, typeof(GUISkin), true) as GUISkin;
    And after, you must have something like that:
    $GUISkin.jpg
    You can select a GUI Skin created separately, and directly design your menus from this GUISkin.
     
  7. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    Currently MultiOnline is a Client/Server multiplayer system, so it's not designed for that. The next version will include a dedicated server solution, but currently, it's not possible without big modifications.
     
  8. ReaList

    ReaList

    Joined:
    Mar 27, 2014
    Posts:
    13
    I'm sorry, I could not :( give me a small sample ? still did not print the user name and this is important :(
     
  9. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    In any way I'll add this feature in the new version. I have not yet done it, I'm currently finish another feature. I'll post a sample for it as soon I have done it.
     
  10. ReaList

    ReaList

    Joined:
    Mar 27, 2014
    Posts:
    13
    Thanks, I'm waiting as soon as possible
     
  11. TheDevGuy

    TheDevGuy

    Joined:
    Mar 3, 2014
    Posts:
    78
    Ok i managed to assign a skin to the waitroom and the menu.

    Now if i wanted to go more in depth i would obviously need to make a skin for each element (Button, Label, etc). Because obviusly in development and end product you dont nessecarily want one texture for buttons and so on.

    Or would i just need to make a "public variable" and then under the GUIButton in OnGui assign the variable for each element that i like?

    Thanks for the continued support and quality product
     
  12. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    The explanations that I have given you before is for define a GUISkin to a menu.
    You create your GUISkin directly from Unity (Asset / Create / GUISkin). You can define the style of each element from your custom GUISkin (font, button, label...), so you need only one, and assign it your scripts, and define it as skin on your OnGui() functions, as I shown you before.
     
  13. TheDevGuy

    TheDevGuy

    Joined:
    Mar 3, 2014
    Posts:
    78
    Yea i already completed all that, but the problem with the GUISkin is that its applying a global texture to all buttons, etc etc.

    I think i confused you before.

    I was stating if i wanted a different texture for each button, such as a red texture for exit, green texture for online account, and blue texture for online games, etc etc. Not just one texture for all like the GUISkin does.

    Was that more clear now?
     
  14. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    Ok, I understand.
    You can create define a special GUIStyle in the elements you want directly in the function which create the GUI element.
    For example, for a button:
    Code (csharp):
    1. static bool Button(Rect position, string text, GUIStyle style);
     
  15. TheDevGuy

    TheDevGuy

    Joined:
    Mar 3, 2014
    Posts:
    78
    So how would this look if i wanted to change perhaps the ONLINE GAMES button?

    where does the code go, how many lines need editing? where do i plug in the custom texture in at?
     
  16. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    If you want a speacial style for a button, I think that you must define it directly in the OnGui function.
    For you exemple, the button "Online Game" is in MMenu, line 218:
    Code (csharp):
    1. if(GUI.Button(new Rect(0,sizeY,sizeMenuButtonX,sizeMenuButtonY), menuMultiOnlineButton)){
    2. // ...
    3. }
    4.  
    You'll have to define your GUIStyle in this function, in this way :
    Code (csharp):
    1. if(GUI.Button(new Rect(0,sizeY,sizeMenuButtonX,sizeMenuButtonY), menuMultiOnlineButton, YOUR  GUI STYLE)){
    2. // ...
    3. }
    4.  
    Here is the documentation about GUIStyle
     
  17. TheDevGuy

    TheDevGuy

    Joined:
    Mar 3, 2014
    Posts:
    78
    Ok so i made a custom style in that GUISkin called "MyStyle" and then put that name into the script here:
    Code (csharp):
    1. if(GUI.Button(new Rect(0,sizeY,sizeMenuButtonX,sizeMenuButtonY), menuMultiOnlineButton, MyStyle)){
    and all it does is this:
    Code (csharp):
    1. Assets/MultiOnline/Scripts/MMenu.cs(220,121): error CS0103: The name `MyStyle' does not exist in the current context
    2. Assets/MultiOnline/Scripts/MMenu.cs(220,40): error CS1502: The best overloaded method match for `UnityEngine.GUI.Button(UnityEngine.Rect, string, UnityEngine.GUIStyle)' has some invalid arguments
    3. Assets/MultiOnline/Scripts/MMenu.cs(220,40): error CS1503: Argument `#3' cannot convert `object' expression to type `UnityEngine.GUIStyle'
    Do i need to define the gui style as a variable or what? i need specifics when dealing with things like this as im not familiar with GUI elements. please.
     
  18. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    GUISkins and GUIStyles are not the same thing (GUISkins are a collection of GUIStyles), so, you can't put a GUISkin in this place.
    To learn more about GUI elements, here is Unity documentation about customization, and here a video tutorial.

    In all cases, I dont' know how you declared your GUISkin, but you must do as I shown you before:
    - Create your GUiSkin for Unitiy
    - Create a variable for in in your script
    - Create a variable for in in the edition script, and from the inspector, drop your GUISKin in this script
    - Call your GUISkin in your OnGui() function
     
  19. TheDevGuy

    TheDevGuy

    Joined:
    Mar 3, 2014
    Posts:
    78
    ok so this is where im confused.. i dont want to use a GUI skin if i can just use scripting with GUIStyle. This is what ive done so far now please let me know why i cant see anything in the MMenu inspector. Id assube its because i need something similar to what i did before in the MMenuEditor script?

    MMenu Script
    Code (csharp):
    1. //global parameters
    2. public GUIStyle myStyle;
    3.  
    4. //view online account
    5. if(GUI.Button(new Rect(0,sizeY,sizeMenuButtonX,sizeMenuButtonY), menuProfilOnlineButton, myStyle)){
    what do i put in the MMenuEditor so that i can physically see the GUIStyle in the MMenu script inspector?

    and if im using GUIStyle, do i need to also do this? or no i need that :
    Code (csharp):
    1. void OnGUI(){
    2.         GUI.style = myStyle;
     
  20. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    On, you can't do that.

    I realize that you can't access to your GUIStyle from the custom Editor, but you can do something else:

    - Define differents GUISkin for each diffrent element, and put the EditionScript in your Editor for both of them, and you drag and drop your GUISkin from the inspector
    Code (csharp):
    1.  
    2. edit.customSkin1 = EditorGUILayout.ObjectField(edit.customSkin1, typeof(GUISkin), true) as GUISkin;
    3. edit.customSkin2= EditorGUILayout.ObjectField(edit.customSkin2, typeof(GUISkin), true) as GUISkin;
    4. edit.customSkin3 = EditorGUILayout.ObjectField(edit.customSkin3, typeof(GUISkin), true) as GUISkin;
    - If you want use ALL a GUISkin in your GUI, you put this in the OnGUI() function:
    Code (csharp):
    1.  
    2.   GUI.skin = customSkin1;
    3.  
    - If you want use ONLY A STYLE for a special element, you can do that:
    Code (csharp):
    1.  
    2. // Apply the button GUIStlye defined in aGUISkin for this button
    3. GUI.Button(new Rect(0,0,100, 100), "text", customSkin2.button));
    4.  
    In this way, you can access on each GUIStlye defined in a GUISkin in this way:
    customSkin.button
    customSkin.label
    customSkin.textField
    customSkin.box
    ...
     
  21. ReaList

    ReaList

    Joined:
    Mar 27, 2014
    Posts:
    13
    Waiting for one week :( When will you make examples ?
     
  22. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    I told you about post samples only two days ago !
     
    Last edited: Apr 27, 2014
  23. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    I would like to recall that the support is only for the current features of MultiOnline.
    I can't develop custom features for each user, I can tell you a way to do it if I have an idea about it, but that's all. Create your own features is part of the work you have to do to develop your game.

    The playername display is a feature which will be integrated in the V3, so you'll get it in the next update.

    If you can't wait for it, you can code it in this way:
    - Create a new RPC function in MNetwork which receives a playername and a position as parameters, and save these parameters in a list.
    - In MNetwork Update() function, call this RPC function to send the player's current position (playerPrefabPosition) and the player name(playerDataSrc.nameInGame) to the other players (RPCMode.Others).
    - Create a OnGUI() function somewhere where you browse your position list to display the players names above the players (using the players's position you have saved in this list).
     
  24. ReaList

    ReaList

    Joined:
    Mar 27, 2014
    Posts:
    13
    Could you give examples with video ?
     
  25. TheDevGuy

    TheDevGuy

    Joined:
    Mar 3, 2014
    Posts:
    78
    None of this makes sense, everything that i try that you suggest comes up with errors and this is such a hassel just to swap some GUI textures around... To be honest if you can supply what the whole script looks like with the style and such for the editor script and the main script that would help becuase i am doing what you tell me and im getting nowhere. Ive read the documentation and i still dont get this, its rediculous.

    Some people need step by step and your instructions are hard to read when you try to type ENGLISH and say things like "If you want use ALL a GUISkin", that doesnt even make sense.
    If you can, PM me what the finished scripts is supposed to look like and not bits and pieces here and there becuase im getting nowhere with this and its irritating to say the least because i dont understand it.
     
  26. ReaList

    ReaList

    Joined:
    Mar 27, 2014
    Posts:
    13
    Hi,

    Version 3 will be released when ?
     
  27. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
    Hi there, love this asset, it works really well! However, I've had two issues with it and cant work out what to do, hopefully I can find some help here. SHould be basic stuff.
    So first of all, the trail renderer doesnt show for other players on multiplayer. Its using a special trail renderer, this one I believe
    https://www.assetstore.unity3d.com/en/#!/content/16076

    But it shouldnt be too different. So yeh, it shows for the main player, but not others. Odd. So yeh, thats my first issue.

    My second it a little more complex, but still pretty basic. I have a script attached to each player which means if they hit the back part of another player (EnemyTriggerOne, Two, or three) it adds 100 points to the score, and shows that on a GUI text. So, it works, but the issue is, although each player has their own independent camera, the GUI label overlays on other players. So lets say I add 100 points, that will show up on my player AND another player in the exact same play with the players points behind it. Heres the script

    Really hope you get back to me ASAP

    Thanks

    P.S. Sorry, just realised this is MultiOnline and not MulitLan, and I use MultiLan. Still, the same fix may apply
     
    Last edited: May 14, 2014
  28. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    How do you apply this renderer ? If it's from a script, can you show me it ?
    There is a function in MNetwork which disable the renderer when players are in the waitroom (line 536), and an other which enable it when player is in game (line 554), maybe there is a problem here.
    The function EnabledPlayer() is called when the game level is loaded -> OnLevelWasLoaded(), line 707, you can check that this function is well called (put a Debug.Log on it, and check that your message appears when your player enter in the game map).

    I think that your problem doesn't come for your script, it's a basic OnGUI() function.
    Did you well integrate you player as explain in documention and video tutorial ?
    Maybe you didn't drag the player's camera in the field "Camera Player" of the script MPlayerNetwork, so each player receive the GUI of all others.

    No problem, the two asset use the same base.
     
  29. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
    Well I just managed to fix the part about the trail, I didnt add the MP network scripts and all that, so sorry about that, that was my fault. However, for some reason I do still get the GUI issue, where it shows on every camera. I've put the camera on the MPlayerNetwork script, on my player prefab, and updated the spawn to include this new prefab, so thats not the issue. Any help with that?
    I havent attached the MPlayer movement script because I have my own movement script. Could that be why?
     
  30. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    No, MPlayerMovment script is made for the sample, it can be remove without any problem.

    But about the script you show me before, with your OnGUI function, I guess you attached this script to your player ?
    Did you delete it for the others networkViews, as explain in documentation ?
    You have to delete each script attached to the other players in MPlayerNetwork Start() function.

    MPlayerNetwork Start() function (line 14) :
    Code (csharp):
    1.  
    2. void Start () {
    3.     if (!networkView.isMine) { // If this is not my player
    4.         Destroy(cameraPlayer); // Destroy camera
    5.         this.enabled = false; // Disabled this script  
    6.         this.GetComponent<MPlayerMove>().enabled = false; // Disabled PlayerMove script -> You can remove this line since you don't use MPlayerMove
    7.         this.GetComponent<YOUR SCRIPT NAME>().enabled = false; // You have to disabled each script attached to your player in this way
    8.     } else  {// If it's my player : search the networkManager component
    9.         //...      
    10.     }  
    11. }
     
  31. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
    Yes its attached to the player game object that the camera is also attached to. Also, all players use the exact same prefab, of course.

    I dont fully understand what you mean, so when MPlayerNetwork is on the player, I delete my custom made scripts? Then how does it use them? And do I delete things like rigibody? I'll read through the documentation again as well, that would help.

    Also, one more issue I didnt notice before, but my player is duplicating, theres two of them for each one player. The other players can see the dupes, but it follows the same movement as the real player (e.g. when you press w both go forward) and can move stuff on the players screen that the others cant see being moved.
     
  32. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    I'm sorry if sometimes I seem say strange things, english is not my first language, so I try to say things as simple as possible, but it's possible that sometimes it have no sense, I'm sorry for that !

    In fact, when you have many players are in game, the scripts make no difference between your current player and the others.
    That mean that if somebody move his player, it will also move your player, and all the others.
    For this reason, we have to disable all the scripts of the other players, else, when something happen to an other player, it also happens to our own player: in your case: if a player try to display something with the OnGUI() function, all players will display it.

    The Start() function of MPlayerNetwork is here for that: it disable the scripts of the other players, but the script of our current player remains active =>
    Code (csharp):
    1. if (!networkView.isMine) { // That mean "if the current player is not mine"
    Is it a little more clear now ?

    First, delete all the scripts of the other players from MPlayerNetwork Start() function, as I shown you before. Not only the script which display the GUI but your movement scripts too, and all the other scripts that you have attached to your player.
    It may also resolve your problem.

    MPlayerNetwork Start() function:
    Code (csharp):
    1.  
    2. void Start () {
    3.         if (!networkView.isMine) { // If this is not my player
    4.             Destroy(cameraPlayer); // Destroy camera
    5.             this.enabled = false; // Disabled this script  
    6.             this.GetComponent<NAME OF YOUR SCRIPT>().enabled = false; // Disable all the attached scripts in this way
    7.         } else  {// If it's my player ..
    8.             //...
    9.         }  
    10.     }
    11.  
     
  33. lynn717

    lynn717

    Joined:
    May 17, 2014
    Posts:
    1
    I just want to buy, because it's really needed, there is only one problem, that is in some games we need two teams and can this kit separates the players into two teams,in the menu? The players can choose which team they will join. Or I can modify it myself ?
     
  34. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
    Sorry I'm late to respond, I had a few things to sort out. I just dont understand, so I delete every script off my player. But then it doesnt do anything, how do I move it without a movement script attached to the player? If I just have network view, MPlayer Network and a rigibody and that kind of thing, how does it work with the scripts I made for my player, like my movement script?
     
  35. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    Hi,
    The asset doesn't have team system, but you can modify it yourself without any problem: the goal is that you adapt it to your needs.
    Here is a video of a user which has add his own team system: https://www.youtube.com/watch?v=Mr_KRrM_-aY&feature=youtu.be
     
  36. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    As I told you, the scripts are not deleted for your current player.
    When you are in game, your player have still all the scripts that you attached on it. Your player can so move, and do everything which is coded in your scripts.
    The scripts are disabled only for your "view" of the other players.
    That mean that each player has his scripts attached to him in his current view, but the scripts of the other players are deleted for his view.
    ... I'm sorry, it's quite hard to explain !

    I'll try to with an example:
    Imagine that you have two players: Player A and Player B.
    Each player have the game loaded in his computer, and are in game.
    Player A disables all the scripts of Player B for his instance of game, but he keep all these scripts active for him.
    And Player B disables all the scripts of Player A for his instance of game, but he keep all these scripts active for him.
    So each player has his own scripts active and can do everything without problem.
    If you don't do that, when Player A will move, Player B will move exactly in the same way, since the game make no difference between Player A scripts and Player B scripts. So when Player A will call the function "Move()", this function will be call to all the other players.

    And maybe you could ask: but in this case, how Player A can know if Player B is moving ?
    The NetworkView are here for that.
    The NetworkView synchronizes the players' positions each time one of them is moving.
    You can read this, and this about NetworkView, it may help you to understand better how does it work.
     
  37. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
    Okay, so I have 1 player prefab, I use the exact same prefab for all players, because thats how the spawn works, you put your single player prefab into the spawns prefab.

    Ive attached my inspector view for my player. Do I just delete everything off this apart from your two scripts, and then attach that to the spawns prefab? Is that all I do? I should mention, these are attached to my player, so is my camera, these are not attached to my camera or anything. SO I just delete all these off my player, and put that in the spawns prefab?

    $Example.png

    P.s. I got rid of the score script, so no need to worry about that anymore, its just about the problems with each player replicating itself.
     
  38. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
  39. Dinrae

    Dinrae

    Joined:
    Dec 19, 2012
    Posts:
    29
    Hello,

    When you say that MultiOnline is compatible with webplayer, does that mean webplayer can host a server/game session?

    Thanks!
     
  40. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    Ok, don't remove anything on your prefab, just replace your Start() function in MPlayerNetwork by this one:

    Code (csharp):
    1.  
    2. void Start () {
    3.         if (!networkView.isMine) { // If this is not my player
    4.             Destroy(cameraPlayer); // Destroy camera
    5.             this.enabled = false; // Disabled this script  
    6.             this.GetComponent<CarControls>().enabled = false; // Disabled CarControls script   
    7.             this.GetComponent<SmokeTrail>().enabled = false; // Disabled SmokeTrail script 
    8.             this.GetComponent<DestroyWithCColide>().enabled = false; // Disabled DestroyWithCColide script 
    9.         } else  {// If it's my player : search the networkManager component
    10.             networkSrc = GameObject.Find("NetworkManager(Clone)").GetComponent<MNetwork>();
    11.             networkSrc.PlayerSpawned(); // Informs the other players that I'm spawned          
    12.         }
    13. }
    14.  
    That's all
     
  41. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    Yes, a player from webplayer can host a game. He just have to open the game's port on his router.
     
  42. reaperkan

    reaperkan

    Joined:
    Aug 5, 2013
    Posts:
    15
    how do you do that?
     
  43. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    Port forwarding is necessary to host a game, it is explained in documentation , but I didn't show how do it since it despends of your web provider. I found this tutoral which could help you: https://www.youtube.com/watch?v=usSpl0yJFnY.

    That's quite easy to do, you must enter the IP for your server in your web browser, so that you will access in your server admin. From there, you'll have to find the menu to open a port; and you open (choose the one you want) a port for your computer's IP in TCP and UDP, and that's all. After that; when you'll host a game from MultiOnline, you'll have to enter the port you opened in the field "game port".
     
  44. reaperkan

    reaperkan

    Joined:
    Aug 5, 2013
    Posts:
    15
    That means going commercial with this asset won't be helpful?
     
  45. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    I am not sure that I understand what you mean. A lot of commercial games use a similar multiplayer system.
     
  46. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
    I know this might be an odd question, but how can I make it so the player spawner spawns from more than one prefab, and randomly selects one player to be this other prefab?
     
  47. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    If you want that a player spawns many prefabs, you can call the player instantiation (Network.Instantiate()) many times in MSpawn, line 26. You'll have as much prefab as you had call Network.Instantiate().
    ... But I don't really understand the second part of your question...
     
  48. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
    Well what I mean is, lets say I have 4 players. 3 Players play as the 1 prefab thats normally with the spawn gameobject, right. And then the 4th player spawns as this second prefab. But which player is the 4th player is randomly determined.
     
  49. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
    Alright, so the above is no longer as big an issue, I now have an issue with this script (also, I dont think I've said which is very rude of me, thank you so much for all the help, you've been fantastic!)

    Okay, so I changed my car script which is fine with multiplayer, but now it turns mesh render on and off at the press of Space. However, it seems to only be doing that for the players camera, when space is pressed the mesh renderer is still on for other players watching the player who is pressing space.

    Now if this is a concept that cannot be done within multiplayer, any alternative would be helpful but not necessary if it is too hard, as I do have a backup solution.

    As I said, thank you ever so much for your help
    Tom
     
  50. VirtuElle

    VirtuElle

    Joined:
    Jan 27, 2013
    Posts:
    458
    Ok, so you want that a player can turn off his mesh renderer, and all other players must see that this player turned off his mesh renderer, it's that ?
    In a multiplayer game, you have to "say" to the others players when you do something, so, the current player must send a RPC function to the other players to say them that he had turned off his mesh renderer.

    You could try something like that :
    Note: I didn't tested it, but I hope it will run, just check that my unityscript is right ( I never use it, I always use C#, so I'm not totally sure about the variable declaration).

    Code (csharp):
    1.  
    2. var WheelFR : WheelCollider;
    3. var WheelRR : WheelCollider;
    4. var WheelFL : WheelCollider;
    5. var WheelRL : WheelCollider;
    6.  
    7. var Speed = 10;
    8. var Breaking = 20;
    9. var Turning = 20;
    10.  
    11. function Update () {
    12.  
    13.     WheelRR.motorTorque = Input.GetAxis("Vertical") * Speed;
    14.     WheelRL.motorTorque = Input.GetAxis("Vertical") * Speed;
    15.  
    16.     WheelRL.brakeTorque = 0;
    17.     WheelRR.brakeTorque = 0;
    18.     renderer.enabled = true;
    19.  
    20.  
    21.     WheelFL.steerAngle = Input.GetAxis("Horizontal") * Turning;
    22.     WheelFR.steerAngle = Input.GetAxis("Horizontal") * Turning;
    23.  
    24.     if (Input.GetKey(KeyCode.Space)){
    25.         WheelRL.brakeTorque = Breaking;
    26.         WheelRR.brakeTorque = Breaking;
    27.         renderer.enabled = false;
    28.         networkView.RPC ("RendererEnabled", RPCMode.Others, 0,networkView.viewID);
    29.     } else {
    30.         networkView.RPC ("RendererEnabled", RPCMode.Others, 1, networkView.viewID);
    31.     }
    32.  
    33. }
    34.  
    35. // RPC function
    36. @RPC
    37. RendererEnabled(var parameter:int, var viewId:NetworkViewID ){
    38.     NetworkView view = NetworkView.Find(viewId); // Search networkView from the parameter received
    39.     GameObject gamePlayer = view.observed.gameObject; // Get the player gameObject from the networkView
    40.     if(parameter == 0){
    41.         gamePlayer.renderer.enabled  = false;
    42.     } else {
    43.         gamePlayer.renderer.enabled  = true;
    44.     }
    45. }
    46.  
    47.  

    Don't say that, there is always a solution ;)
     
unityunity