Search Unity

GTGD's Unity Multiplayer Tutorials

Discussion in 'Community Learning & Teaching' started by GTGD, Feb 7, 2012.

?

Please select each option you agree with (you can select multiple options)

Poll closed Dec 22, 2015.
  1. I like that the videos are covering a complete project.

    230 vote(s)
    88.1%
  2. I find the videos are detailed enough for me to understand and follow.

    197 vote(s)
    75.5%
  3. I find the video quality is clear enough.

    186 vote(s)
    71.3%
  4. I find the audio quality is clear enough.

    180 vote(s)
    69.0%
  5. The narrator doesn't send me to sleep.

    143 vote(s)
    54.8%
  6. In general the topics covered are interesting.

    170 vote(s)
    65.1%
  7. I find the website useful.

    130 vote(s)
    49.8%
  8. The Gamer To Game Developer logo looks good.

    119 vote(s)
    45.6%
  9. I would like to suggest topics that GTGD should cover in the future.

    103 vote(s)
    39.5%
Multiple votes are allowed.
  1. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Some of the code won't work in Unity 4 but it's not too much. I'd recommend watching the second video of series 2 if you're sticking with Unity 4 so that you'll at least have a good idea of where the code needs to change. The main issue is with the communication window in video 8.

     
  2. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Good work im. You've improved the code and made it simpler to understand as well so good job.

    That's right about the ray casting. If the blaster gets instantiated too close to the floor it will just fly through. I have thought of firing a raycast in the start function from a position just a bit behind where the blaster is instantiated, and if that ray hits something then the blaster is immediately disabled (destroyed as you've done) and the explosion particle effect instantiated.

    Btw, I don't have any plans to use Photon in the near future. For now I'll just be using Unity's inbuilt networking as it is pretty decent once you get used to it, and in my case my code is quite inefficient in a number of places, and still the Unity networking holds up well. I'll be ironing out these inefficiencies in the newer videos and one of the main culprits at the moment is the way I update player movement across the network. My aim is to have the networked mecanim animation videos start coming out in October and there I'll share how I keep the animation and movement synced with reasonable efficiency. It's better than what you'll see me show you in video 5.

    With Unity 4 you will run into a few problems but video 2 of series 2 will help you understand what those are.
     
  3. ilgazdemirel

    ilgazdemirel

    Joined:
    Aug 1, 2013
    Posts:
    3
    Hİ GTDG,

    I am on video 3, using Unity 4.2. I am getting the following errors

    rc.right != m_GfxWindow->GetWidth() || rc.bottom != m_GfxWindow->GetHeight()

    GUI Window tries to begin rendering while something else has not finished rendering! Either you have a recursive OnGUI rendering, or previous OnGUI did not clean up properly.

    !rcolor->m_Surface

    RenderTexture error: failed to retrieve color surface [unknown error, code 0x1]

    Perhaps this is to do with Unity 4 or perhapsI am doing something wrong. Can you help please? wBR
     
  4. ilgazdemirel

    ilgazdemirel

    Joined:
    Aug 1, 2013
    Posts:
    3
    Sorry, re openning Unity fixed the problem.
     
  5. ilgazdemirel

    ilgazdemirel

    Joined:
    Aug 1, 2013
    Posts:
    3
    For newbies like me, doing this on Unity 4.2

    Video 3:
    Ellipsoid Particle emitter is under Component>Effects>Legacy Particles
    Particle Animator is under Component>Effects>Legacy Particles
     
  6. Augustoandretta

    Augustoandretta

    Joined:
    Sep 18, 2012
    Posts:
    8
    Can you help me? i'm looking in the series 1 , but yestarday i close the unity, i today i try open my project and they are saying that i must upgrade the project to new version of unity,
     
  7. Welias D.

    Welias D.

    Joined:
    Jun 12, 2013
    Posts:
    36
    Most likely you need to watch this video:

    http://www.gamertogamedeveloper.com/series-2/video-2
     
  8. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    hi i just saw and voted for it on greenlight and posted nice comment!

    also consider putting it in unity store under complete projects

    best of luck
     
  9. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Thanks im.

     
  10. TiagoCarvalho

    TiagoCarvalho

    Joined:
    Apr 9, 2013
    Posts:
    49
  11. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Hey your project is coming along really nicely and it looks like it will get better and better with time. Maybe on your Unity forums page you can add a bit more description of what the game is about, what the main features are, and keep the page updated as you progress.

     
  12. Grim Reaper

    Grim Reaper

    Joined:
    Aug 28, 2013
    Posts:
    2
    Hi, can anyone help me with my BlasterScipt please ?

    I wanted to have the ConstructionBlocks removed by the Blaster Projectiles instead of the FireBlockEraser, so instead of importing the FireBlockEraser script i copied the RPC and the function from the FireBlockEraser script into the BlasterScript.

    Here's the RPC

    Code (csharp):
    1. if(hit.transform.tag == "ConstructionBlock")
    2. {
    3. //Send an RPC to the server and inform the block on the
    4. //server that it has been hit and needs to be removed.
    5.                
    6. networkView.RPC("TellServerConstructionBlockIsHit", RPCMode.Server, hit.transform.name);
    7. }
    8.  
    And here's the function copied from the FireBlockEraser to the BlasterScript

    Code (csharp):
    1. [RPC]
    2. void TellServerConstructionBlockIsHit (string blockName)
    3. {
    4. GameObject block = GameObject.Find(blockName);
    5.        
    6. ConstructionBlockAsksToRemoveItself script = block.transform.GetComponent<ConstructionBlockAsksToRemoveItself>();
    7.                
    8. script.iAmHit = true;
    9. }
    But when i shoot a block with the Blaster i get an error
    "RPC call failed because the function 'TellServerConstructionBlockIs*Hit' does not exist in any script attached to'Construction Block 1' "

    And as the original FireBlasterScript that contained the RPC and function was never attached to the Construction block i can't figure out why i'm getting this error.

    Can anyone help me please ?
    Thank you.
     
  13. Grim Reaper

    Grim Reaper

    Joined:
    Aug 28, 2013
    Posts:
    2
    Can anyone see what i'm doing wrong ?

    Please help me i'm stuck on video 15 until i can get this fixed and i really want to finish the tutorials.

    Thanks
     
  14. rene.haefferer

    rene.haefferer

    Joined:
    Dec 27, 2012
    Posts:
    7
    Dear Everyone here.

    I followed along twice setting the Server up.

    All works nice but only one Part wont work and i cant figure out what the Problem is.

    So I use the Settings given in the Video, for testing Purposes i use 127.0.0.1

    I have this issue comin up:
    from an built exe to the editor as Server => Teamselection wont work, rest does
    from built to built server => teamselection wont work, rest does
    from editor to builtserver it works as shown in the video

    I Use Unity4, default IP as in Video and default Port 26500

    What can I do to get it running?
    Is there some fix or where can i look for solving the issue?

    Regards
     
  15. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
  16. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    It was probably a temporary outage. No I haven't done any lag compensation so movement does look choppy with increasing latency. However my hit detection system is designed to cope reasonably well with a higher latency.

    There was an old multiplayer project example from Unity that did have a script for trying to cope with lag though I don't know where it is now.

     
  17. lordmazus

    lordmazus

    Joined:
    Feb 23, 2013
    Posts:
    8
    Hello, why i cant see the Window GUI in Unity 4 .2 ?

    Thank you for help !
     
  18. kcirdnehnosaj

    kcirdnehnosaj

    Joined:
    Jul 30, 2012
    Posts:
    5
    If I buy the project package from your website, do we get future updates for free? I cant wait to see new videos :)
     
  19. kcirdnehnosaj

    kcirdnehnosaj

    Joined:
    Jul 30, 2012
    Posts:
    5
    Nevermind. It looks like its just for Series 1.
     
  20. PurpleFlow

    PurpleFlow

    Joined:
    Sep 16, 2013
    Posts:
    7
    GTGD, I want to thank you for taking the time and effort to create these tutorials for us noobs. I'm sure many people cried (from joy) when they found your series, including myself. Keep up the good work!
     
    Last edited: Sep 18, 2013
  21. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Thanks PurpleFlow! Your post means a lot to me. I'm still learning a lot myself so maybe I could call myself a higher level noob :D.

     
  22. Christian-Tucker

    Christian-Tucker

    Joined:
    Aug 18, 2013
    Posts:
    376
    Very Nice, one of the things I disliked about this series was how in-depth you are. I ;like to learn from the code, and a quick explanation, I felt like some of your two hour videos could be summed up in 20 minutes, and it annoyed me, honestly, but you've dedicated a LOT of time into this, thank you. I learned a great sum.
     
  23. Fenix3D

    Fenix3D

    Joined:
    Jul 18, 2012
    Posts:
    9
    Good tutorials man, GJ !
     
  24. DryTear

    DryTear

    Joined:
    Nov 30, 2012
    Posts:
    312
    Give this man a cookie, this guy signed up for UDN account just to post his feelings to this amazing tutorial. amazing
     
  25. SubliminallySublime

    SubliminallySublime

    Joined:
    May 31, 2013
    Posts:
    2
    Are you still making these videos?
     
  26. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    No I'm not. I put series 2 on hold because I'm working on a new project which should become a complete game. It's a tycoon game drawing from my real life industry experience, well I'll be bringing in the fun stuff, not the boring stuff :p. I'm currently scoping it and developing the game play concept and I haven't touched any code or art yet, so I haven't anything neat to show yet.

     
  27. MrMassively

    MrMassively

    Joined:
    Sep 4, 2013
    Posts:
    115
    Love your Tutorials,

    you narrate really great and so easy to understand and follow.

    got a little request tho,

    maybe when you have time, would you mind adding a simple matchmaking script tutorial?

    something like system matchmake players and beguin game as soon game room is full? instead of joining one by one?

    thanks again for the great tuts
     
    Last edited: Oct 7, 2013
  28. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Thanks! I've put tutorials on hold though because I've commenced work on a new game Rolling Stock Engineering Tycoon.

     
  29. ReStrooke

    ReStrooke

    Joined:
    Oct 15, 2013
    Posts:
    2
    Hi gtgd.
    I really LOVE your videos but i'm stuck at the Multiplayer Spawn System...
    Every time i try to join my own Server the console says:

    NullReferenceException
    UnityEnginge.Component.get_transform () (at C:/BuildAgent/work/ea95e74f6e5f192d/Runtime/ExportGenerated/Editor/UnityEngineComponent.cs:21)

    NullReferenceException
    UnityEngine.Component.get_transform () (at C:/BuildAgent/work/ea95e74f6e5f192d/Runtime/ExportGenerated/Editor/UnityEngineComponent.cs:21)
    CameraScript.Update () (at Assets/Scripts/Multiplayer/CameraScript.cs:43)


    It's your camera script... it should work ;(
    The gamewindow freezes black (With the Menue) but i can still move around (i can see it in the editor).

    Please help me asap because it's the only thing i'm stuck in ;)
     
  30. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Does your camera have the tag MainCamera?

     
  31. ReStrooke

    ReStrooke

    Joined:
    Oct 15, 2013
    Posts:
    2
    Worked ;)
    But now i cant move my head up and down. left and right works...
    ;)
     
  32. Origami

    Origami

    Joined:
    Oct 1, 2013
    Posts:
    5
    NullReferenceException: Object reference not set to an instance of an object
    BlasterScript.Update () (at Assets/Scripts/BlasterScript.cs:75)

    what does this mean and how do I fix it
    I'm at the end of video 6
    thanks in advance for any help
    I have finished the video and am testing it
     
    Last edited: Oct 19, 2013
  33. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    I think you haven't configured the MouseLook script on the CameraHead.

    The error is saying that something can't be found. In the code it is referring to something but in the game it doesn't exist. When you double click on the error it will go to the script to line 75 (as per the error message) and highlight it to point out that it's struggling there. From there you need to figure out what could be wrong that it can't find the object it's looking for.

     
  34. Origami

    Origami

    Joined:
    Oct 1, 2013
    Posts:
    5
    Thanks, very helpful
    probably should have just looked at the Error
     
  35. Origami

    Origami

    Joined:
    Oct 1, 2013
    Posts:
    5
    Also, is the game supposed to function on multiple computers at this point?
    I tried it, and it didn't work, is this the game of a firewall
     
  36. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    I recommend that you watch video 33 and I think you'll then understand what to do.

     
  37. Origami

    Origami

    Joined:
    Oct 1, 2013
    Posts:
    5
    Thank you, sorry to keep asking so many questions.
    on video seven, the respawn button doesn't work. I get no errors, but it just doesn't appear when I kill the opponent
    I have imported the spawnplayer script so either its something outside of the code, or is an error in a different script
    love the tutorials by the way
    thanks again for responding
     
  38. DryTear

    DryTear

    Joined:
    Nov 30, 2012
    Posts:
    312
    hows your progress so far?
     
  39. Origami

    Origami

    Joined:
    Oct 1, 2013
    Posts:
    5
    What, mine?
     
  40. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    My rough guess Origami is that maybe you haven't edited the HealthAndDamage script in video 7 sufficiently so it is never informing the spawnscript that the player has been destroyed.

    Hey DryTear, I've put series 2 on hold because I'm working away on a new game; Locomotive Tycoon. I'm just in the concept phase at the moment with it and I'm still exploring other game concepts that I could develop as well. I'm still thinking about the RPG game I talked about in the second half of video 34. Greenlight concepts area is pretty neat because it really helps with evaluating whether a concept might become something that people will find fun and will be interested in investing their precious game time into.

     
  41. Dragonxtamer

    Dragonxtamer

    Joined:
    Nov 10, 2013
    Posts:
    23
    I'm sure your busy but I'm wondering if you can tell me how to make the multiplayer chat system work for private chat, group, clan ect.
     
  42. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    You could overhaul the system so that the player can choose to send a message to a specific player, or to players on their team only, and the key to achieving this is by controlling who the RPC is sent to (you just need the Network ID of that/those players). Currently it is RPCModel.All so you need to change the code so that you can target who to send the RPC to.

     
  43. fearlessneon

    fearlessneon

    Joined:
    Nov 8, 2013
    Posts:
    12
    I was wondering could you make a episode where the player has to login and create and account and no one can create an account with the same username or email as other player.
     
  44. fromIndia

    fromIndia

    Joined:
    Nov 13, 2013
    Posts:
    2
    Hi GTGD,

    Voice 10/10
    Explanation 10/10 (very clean point to point, there is no where i couldnt understand)
    YOUR WEBSITE LOGO LOOKS AWESOME :) :)

    I really like your teachings, those are very understable and informative. I never thought i could developer a multiplayer game on my own. you made it very easy. Am developing a game, in which i dont want to use mouse to rotate the view, instead i want my left and right keys do the job. what need to be done? what script need be changed? what script need to be removed? Am really looking forward to your reply.
     
  45. gmxmanyolis

    gmxmanyolis

    Joined:
    Nov 17, 2013
    Posts:
    1
    hello everyone, i need help with the networking. i copied the codes and everything works fine when im running multiple clients on one computer but when i tried to communicate with 2 computers it didnt work. i tried to find a solution but i cant maybe it is something obvious that i missed.


    p.s. keep going with these videos. They are the best unity tutorials.
    p.s.s. dont be so tidy:D
     
  46. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Sorry for the slow replies guys.

    I don't know how to make a login system but one of my YouTube viewers has done it. Here's his YouTube channel http://www.youtube.com/user/VegasMovieeStudios. Maybe you can ask him how he setup his system, it's more advanced than mine.

    In my setup the MouseLook script is responsible for turning the player and the CameraHead. I think you'd need to adjust the MouseLook script or make your own for using the left and right keys for turning the camera.

    Try putting up a video that shows what is happening and how you are trying to get two computers to connect. If you're able to get a client to connect to your sever on your own computer using localhost then it seems really odd that you can't use Hamachi or port forwarding to connect two computers. Also, in a LAN setup you don't even need to use Hamachi or port forwarding.

     
  47. fearlessneon

    fearlessneon

    Joined:
    Nov 8, 2013
    Posts:
    12
    Can you make a tutorial on an "Auto Updater" so when i update it for example on example.com/blackout1.0.zip is the original page but when it changes like example.com/blackout1.1.zip it will update whats needed.
     
    Last edited: Nov 29, 2013
  48. DryTear

    DryTear

    Joined:
    Nov 30, 2012
    Posts:
    312
    if your gtgd learning tutorials get greenlit, you will continue off with the tutorial for series 2. right?
     
  49. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    @fearlessneon, I think you might be after the capability of Unity Asset Bundles, a Unity Pro feature. Anyone else reading this please correct me if I'm mistaken. http://docs.unity3d.com/Documentation/Manual/abfaq.html

    @DryTear, Definitely I would allocate my time back to series 2, but I really don't think S1 will get greenlit because it's been number 2 for months and the number one software title has also not been greenlit for at least that long as well. Ultimately it's up to the publisher on what they want to distribute on their platform. In the meantime though I've been taking my time to prepare concepts for a couple of different games and I've also been learning more of the Unity API and about coding in general so that I can develop a functioning prototype for one of those concepts.

     
  50. leekinon

    leekinon

    Joined:
    Dec 4, 2013
    Posts:
    21
    The player name in the hierarchy still be RedPlayer(clone) or BluePlayer(clone) and not the name i have selected.(GTGD S1.6 Health Damage System)
    There are an error showed in Unity.


    Code (csharp):
    1. NullReferenceException
    2. UnityEngine.GameObject.GetComponent[PlayerDatabase] () (at C:/BuildAgent/work/ea95e74f6e5f192d/Runtime/ExportGenerated/Editor/UnityEngineGameObject.cs:27)
    3. PlayerName.UpdateLocalGameManager (System.String pName) (at Assets/Scripts/PlayerName.cs:70)
    4. PlayerName.Awake () (at Assets/Scripts/PlayerName.cs:52)

    Is it related to my animation script? (I use JavaScript)


    Code (csharp):
    1. var WalkAnimSpeed : float = 1.0;
    2. var RunAnimSpeed : float = 1.0;
    3. var JumpAnimSpeed : float =1.0;
    4. var JumpBlendSpeed : float =1.0;
    5. var AttackBlendTime : float =0.05;
    6.  
    7. static var move:boolean=false;
    8. var model : GameObject;
    9.  
    10. enum AniState {idle,
    11.           run,
    12.           walk,
    13.           jump_pose}
    14.  
    15.  
    16. function Start()
    17. {
    18.  
    19.     if(!networkView.isMine)
    20.     enabled=false;
    21.     animation.wrapMode  =   WrapMode.Loop;
    22.     animation.Stop();
    23. }
    24.  
    25.  
    26.    
    27.  
    28. function Update ()
    29. {
    30. if(!networkView.isMine)
    31. return;
    32.  
    33.  if ((Mathf.Abs(Input.GetAxis("Vertical")) > 0.2) || (Mathf.Abs(Input.GetAxis("Horizontal")) > 0.2))
    34.     {
    35.  
    36.         if(Input.GetButton("Run"))
    37.         {
    38.  
    39.             move=true;
    40.             networkView.RPC("PlayAnimation",RPCMode.All, "run");
    41.             animation["run"].speed = RunAnimSpeed;
    42.             if(Input.GetAxis("Vertical") < -0.2)
    43.             {
    44.                 animation["run"].speed = -RunAnimSpeed;
    45.             }
    46.         }
    47.        
    48.  
    49.         else
    50.         {
    51.  
    52.             move=false;
    53.             networkView.RPC("PlayAnimation",RPCMode.All, "walk");
    54.             animation["walk"].speed = WalkAnimSpeed;
    55.             if(Input.GetAxis("Vertical") < -0.2)
    56.             {
    57.                 animation["walk"].speed =-WalkAnimSpeed;
    58.             }
    59.         }
    60.     }
    61.    
    62.  
    63.     else
    64.     {
    65.        
    66.         move=false;
    67.         networkView.RPC("PlayAnimation",RPCMode.All, "idle");
    68.     }
    69.    
    70.  
    71.    
    72.  
    73.  
    74.     if(Input.GetButton("Jump"))
    75.     {
    76.         networkView.RPC("PlayAnimation",RPCMode.All, "jump_pose");
    77.         animation["jump_pose"].speed = JumpAnimSpeed;
    78.     }
    79.    
    80. }
    81.  
    82.  @RPC
    83.  function PlayAnimation(animationName : String)
    84.  {
    85.      model.animation.CrossFade(animationName);
    86.  }

    Is it need to have some change in my animation script for the player name function?