Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Question to the group. How long did it take you to go through the videos and to create and implement the procedures...(so I can block out some time)
     
  2. Divided

    Divided

    Joined:
    Oct 28, 2012
    Posts:
    2
    Great tutorial. I wanted to follow the whole thing but I get error. video 3 when adding Blaster hit and destroy part. spent a few hours cant find the problem.


    //if collider has Tag of Floor.
    if(hit.transform.tag == "Floor")
    (
    expended = true;
    //MakeProjectile invisable.
    myTransform.renderer.enabled = false;
    //Turn off the Projectile Light.
    myTransform.light.enabled = false;
    )
     
    Last edited: Nov 14, 2012
  3. ChaosMax

    ChaosMax

    Joined:
    Jun 23, 2010
    Posts:
    21
    Just voted Yes on your greenlight page.

    Every one else who likes his tutorials go here and watch video 34 to learn more and then get over and vote for GTGD.

    Good Luck! :)
     
  4. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    You forgot to tell me what the error that comes up in your log is :)
     
  5. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    You're welcome GlitchBait! There will be future videos and a series 2!

    Thanks ChaosMax, yes the more voters the better! My Greenlight efforts aren't going too well but I've decided that there will be a series 2 and I'll aim for the first video to come out next Feb/March. I'll be keeping the Master Server for series 3 as there are a couple of very important things that I need to cover before then. I'll be making a video soon to let everyone know and what to expect in series 2.
     
  6. Divided

    Divided

    Joined:
    Oct 28, 2012
    Posts:
    2
    I get these errors. not sure what to do. should if statement have {} not () ?

    Assets/Scripts/BlasterScript.cs(47,26): error CS1525: Unexpected symbol `if'
    Assets/Scripts/BlasterScript.cs(54,25): error CS1525: Unexpected symbol `)'
    Assets/Scripts/BlasterScript.cs(62,17): error CS1525: Unexpected symbol `)'
    Assets/Scripts/BlasterScript.cs(63,1): error CS8025: Parsing error

    here is script.

    using UnityEngine;
    using System.Collections;

    /// <summary>
    /// Attatched to the blaster projectile .creates behavior..
    /// </summary>


    public class BlasterScript : MonoBehaviour {

    //Variables.........................................
    private Transform myTransform;
    //Projectiles Flight Speed.
    private float projectileSpeed = 10;
    //Prevent Projectile from cuasing further harm after impact.
    private bool expended = false;
    //A ray projected from proctile to colliders.
    private RaycastHit hit;
    //Range of Ray.
    private float range = 1.5f;
    //Life span of Projectile.
    private float expireTime = 5;
    //EndVariables......................................




    // Use this for initialization
    void Start ()
    {
    myTransform = transform;
    //On Projectile creation start countdown to destroy it.
    StartCoroutine(DestroyMyselfAfterSomeTime());
    }

    // Update is called once per frame
    void Update ()
    {
    //Translate the Projectile in the up direction of Object
    myTransform.Translate (Vector3.up * projectileSpeed * Time.deltaTime);

    //If the Ray hits something then excecute this code.
    if(Physics.Raycast(myTransform.position,myTransform.up, out hit, range)
    expended == false)
    (
    //if collider has Tag of Floor.
    if(hit.transform.tag == "Floor")
    (
    expended = true;
    //MakeProjectile invisable.
    myTransform.renderer.enabled = false;
    //Turn off the Projectile Light.
    myTransform.light.enabled = false;
    )
    )
    }
    IEnumerator DestroyMyselfAfterSomeTime()
    (
    //Wait for the timer to expected time and then destroy Projectile.
    Yield return new WaitForSeconds (expireTime);
    Destroy(myTransform.gameObject);
    )
    }
     
  7. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    @Divided You should be using curly braces {} for blocks of code within if statements and functions. The round brackets () are for passing in parameters.

    I also forgot to mention that you should go to my website and download the scripts from the downloads page so that you can have a good look at my scripts and use them for debugging. Also, watch the videos in HD otherwise the blurriness can be misleading.
     
    Last edited: Nov 15, 2012
  8. madmike6537

    madmike6537

    Joined:
    Aug 20, 2012
    Posts:
    49
    **Ah nevermind, missed the part about checking the box to run in background :) ** Thanks.

    Quick question: Should we also be using these variables for our own program? Or should we find and use our own IP address?

    private string connectToIp = "127.0.0.1";
    private int connectionPort = 26500;

    I cant seem to connect to my own server when I run it for some reason.

    Tutorials are great btw - thanks for posting.
     
    Last edited: Nov 18, 2012
  9. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    127.0.0.1 is your local IP address and allows you to connect to your own computer. This is the IP address that you use for testing purposes but of course you need to tell external clients your actual web IP address so that they can connect to you. Video 33 talks about how to setup a game using Hamachi.

    The connection port 26500 can be whatever you want so long as it's not being used by another program installed on your computer. You must also tell your external clients what port number you're using. The program uses only that port number for sending and receiving communications so if external clients used a different port number they'd never be able to connect to your game because they'd be looking for communications at the wrong port.

    Also make sure that you have Run In Background checked in Edit > Project Settings > Player > Resolution Presentation
     
  10. Juaanma

    Juaanma

    Joined:
    Oct 30, 2011
    Posts:
    6
    Congratulations for the tutorials, they're great for people that is quite new into Unity!
     
    Last edited: Nov 18, 2012
  11. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Thank you!
     
  12. Sevenup

    Sevenup

    Joined:
    Nov 19, 2012
    Posts:
    5
    I also want to thank you for a good tutorial!

    I've put your scripts in my project and it's works really great but I have a little problem with the
    PlayerLabel script !

    I have tried to make the health bar over enemies to disappear
    on maximum distance without result.
    Can you help me with this?

    Thanks again.
     
    Last edited: Nov 19, 2012
  13. madmike6537

    madmike6537

    Joined:
    Aug 20, 2012
    Posts:
    49
    So would I be correct in saying that my friends cannot yet connect to my game until I go through tutorial 33 using hamachi? Since there is no field to input the IP address when you create the server, it simply assigns one, if I give my friends my public IP and have them put that in, will they be able to connect or will I need to use Hamachi first? Thanks!! (I have completed the first seven tutorials so I believe I have most of the networking parts in)

    P.S. I cant seem to run multiple copies of my game - another reason why I was going to have a friend help me test - when I try to run the server in Unity, and then two copies of the game, when I try to open the second copy I get an error. I realize I have to open it from the exe file, but still no luck.

    PSS tutorials just keep getting better - I am really enjoying them and definitely will buy the second ones when you release them.
     
  14. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    @Sevenup, what do you mean by max distance? If you mean that you don't want the health bar to appear over players when they are a certain distance from you then you could include a few lines more in the PlayerLabel script where you check the distance of that player from your player and so only run the code that draws the health bar when they are within a certain distance of your player character.

    @madmike6537 You can actually follow video 33 right after completing video 4. I'd recommend watching video 33 now so that you can see how to use Hamachi to connect between you and an external friend. In that video I also explain how to have a LAN game as well, and it is really simple.

    That's very odd that you can't run multiple copies of the same exe. Does that happen even with the built game that you can download from my website? Out of curiosity what OS are you using?
     
  15. madmike6537

    madmike6537

    Joined:
    Aug 20, 2012
    Posts:
    49
    Hi, I am using Windows 7 64 bit.

    Since posting that I have been able to get it to work - to be honest, I dont know what I was doing wrong before. The only thing I can think that I am doing differently is I created a shortcut to my Exe file to put on my desktop. Regardless, its working now, woot!

    I do have another issue, but its my fault. I must have mistyped some code somewhere so now I get to go figure out where it is, yay isnt debugging fun! lol.

    If you have any tips I wouldnt turn them down! The exact error I am getting is this:

    MissingReferenceException: The object of type 'Camera' has been destroyed but you are still trying to access it.

    Here is what happens:

    I build and run game from unity.
    I then run the game in unity and set up a server
    I then connect to that server with the first build of the game, all is well I have no problems and can play fine.
    Note: at this point on my game running within unity, which is running the server, it uses my player camera on the first player that connected and it follows that person around. Not sure if this is normal.

    Next I open up a third game, and when I connect this is when things get really strange. First I get the error above. Then the the person who just connected loses the ability to move their player correctly - basically the camera script seems to stop working all together.
    The other connected player, (the first connected one) completely disappears and now follows the camera of the last connected player.

    It also tells me I have two listening devices, I assume thats because of the two cameras but I dont see how you would get around that.

    its a mess! I must have messed up something somewhere, so I will have to go back and figure out what I did I guess.
     
    Last edited: Nov 19, 2012
  16. Sevenup

    Sevenup

    Joined:
    Nov 19, 2012
    Posts:
    5
    Yes i meant exactly what you wrote i don't want the health bar to appear over players when they are a certain distance from my player character..
    if you have a large scale level and if you have many players its a bit confusing to se healthbars with player names over the whole level :)

    i dont know if you thought of this but it could be a good update to u script :)
    i've tried to modify your playerlabel script without success and i wonder if you could help me in the right direction?

    Thank you
     
  17. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Lols, you might have fallen asleep while watching video 5, because there the CameraScript is edited so that what you're describing doesn't happen. Also I delete the camera attached to the player prefab so that there is only one camera left in the scene and it will only follow the player character that is under the client's control.
     
  18. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Good point. It is a bit messy seeing a bunch of labels overlapping each other in the distance. I have also sometimes thought that maybe I should have made it so that I have to place my crosshair over the other player to see their health and who they are.

    By the way, It isn't too difficult to calculate the distance from each player prefab in their PlayerLabel script to the player character that is under your control. The simple way would be to:
    1. Create a new public string in the PlayerLabel script that will act as a slot for the name of the player that the distance needs to be measured to (that player is you).
    2. Then you would make the PlayerName script supply your player name to every player character's PlayerLabel script in that new public string. Of course you place this bit of code between if(networkView.isMine....). You could search through players using their tag.
    3. Then in the PlayerLabel script find the player who has that name, it is of course the player character under your control.
    4. Now calculate the distance from this transform to your player character.
    5. Now use this as a condition for the if statement where the health bar is drawn and you are now controlling the display of the health bar using distance.
     
  19. Sevenup

    Sevenup

    Joined:
    Nov 19, 2012
    Posts:
    5
    It is a good solution ! I will try with what you write thank you very much !
    And thanks for a quick reply
     
  20. madmike6537

    madmike6537

    Joined:
    Aug 20, 2012
    Posts:
    49
    Heh yes that could be. It was a long day of tutorial watching :) I am actually trying to make this work with a third person camera script. Its frustrating because everything works perfectly except the camera. When that second player connects, the camera from the first player uses the camera of the second player. I re-watched tutorial five - I see that you just have one main camera in the scene, with the player prefabs having no camera at all. I am just trying to think how that would work with a third person camera I guess.

    maybe I just need to spend some more time reading and understanding how networkview.ismine works and see if I am missing something on how this all works.
     
  21. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Like most hard of hearing people, I don't have any interest in videos and can't use them since there's no subtitles, so additional text based material or subs is a welcome effort. But I feel adding subs to a youtube video would not actually net you any more sales (if monetizing) as I doubt there's many hard of hearing game developers (particularly not many that have made music apps like myself haha)
     
  22. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    I'd like to add in subtitles as everyone has a right to educational material. The problem is that I don't prepare a script for the narrative in my videos, only the actions that I will be performing in Unity and in writing code, and I don't have enough free time to write down all things that I've said and then input them into the video. I'll see if my recording software is able to automatically generate subtitles but I doubt it will be successful because of all the awkward words like; networkView.isMine, Quaternion.identity, etc. which are all nonsensical from an English language perspective. I hope someday I can expand Gamer To Game Developer to be a small team of hobby developers who pool their knowledge and skills together to produce high quality useful learning material, both free and commercial.
     
  23. madmike6537

    madmike6537

    Joined:
    Aug 20, 2012
    Posts:
    49
    Dear GTGD,

    I am running into an issue - please help.

    When I spawn my projectile, I get a null reference error. I have copied it exactly as in your script as follows:

    But I get a reference error on the line starting with Arrow(which is the name of my script) bScript = go... The exact error is:

    NullReferenceException: Object reference not set to an instance of an object

    Do you have any idea why this might be happening? Its causing all kinds of problems for me! :(
     
  24. madmike6537

    madmike6537

    Joined:
    Aug 20, 2012
    Posts:
    49
    I was able to fix this by setting my arrow to instantiate as a transform instead of a gameObject. Now the hits are not registering on the enemy player but I guess I will have to figure that out next.
     
  25. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436

    When you double click on the error which line of code is highlighted? The error that you're getting is a simple one and is saying that some bit of code is trying to find something that doesn't exist. Misspelling names or forgetting to attach public GameObjects in the inspector panel, for the script that expects it, are common causes. Btw, you can insert code in these forums using the "Wrap
    Code (csharp):
    1.  tags around selected text" and that is the way to go to make it easier for people to read your code.
     
  26. GameStar18

    GameStar18

    Joined:
    Aug 30, 2012
    Posts:
    5
    Hello GTGD! Love your tutorials! It is exciting to expand our knowledge of Unity further and learn about online networking too, that certainly isn't something covered in many tutorials at all, at least from what I have found so thanks again for these!

    I am only having one issue. After completing video 6 and player blue gets hit by a blaster I get this error:
    "View ID AllocatedID: 52 not found during lookup. Strange behaviour may occur"
    and
    "Could't invoke RPC function 'UpdateMyCurrentAttackerEverywhere' because the networkView 'AllocatedID: 52' doesn't exist"
    I looked at Blue's trigger and his allocated ID Number is 52 and the parent blue object's is 50. For red it is 200 and red's trigger object is 202, but I don't get that error for red being hit. When hit, blue disappears and the those errors appear like 4 times each. Any ideas on this? I looked through this thread and haven't seen anyone else with this problem and couldn't find a solution.

    Thanks for any help! Keep up the fantastic work!
     
  27. madmike6537

    madmike6537

    Joined:
    Aug 20, 2012
    Posts:
    49
    Hi and thanks for the reply - I was able to get this fixed by changing my projectile to a transform instead of a gameobject.

    ***UPDATE**

    Figured it out - I just had to update my SpawnProjectile RPC function to include a parameter called power that sends the power amount via the RPC - works like a charm now :) On to more tutorials!!!



    I do have one other question though - can you please tell me what you have attached to your projectiles?

    For some reason, my projectile's are only showing movement in the player's screen that shoots them, the other player sees them instantiate, but does not see them move, they just fall to the ground( since they are a rigidbody).

    Do you have a networkview attached to the projectile?
    What about the movement update script or a version of it?

    I guess I am not quite understanding how the players know where my projectile is. I know we use an RPC to instantiate them, but how do they know where it is every frame?
    Any ideas on what I might have missed? Thanks again for all your help.
     
    Last edited: Nov 29, 2012
  28. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    @GameStar I don't know why you'd be having this problem. I'd recommend that you take screenshots of how your player prefabs are setup or maybe a video, and then post it back up here on the forum so that I can see what's happening.

    @madmike I'd recommend that you follow video 3 and apply whatever changes I make to the blaster projectile in later videos. I'd also recommend that you follow the first 10 videos in order otherwise you're going to run into strife. Once you have the fundamentals down then you can go your own way.
     
  29. technotdc

    technotdc

    Joined:
    Oct 21, 2011
    Posts:
    60
    Any chance of someone expert to convert it to Photon server ???????
    (I've tried with the option of converting in Photon .... but then I have no knowledge to fix the scripts)


    Thanks


    (sorry my english)
     
  30. GameStar18

    GameStar18

    Joined:
    Aug 30, 2012
    Posts:
    5
    @ GTGD:
    Turns out after I completed the next video, that problem doesn't happen anymore so that's good news :) Quite interesting.

    Hoping to be able to implement the online functionality of this series into my own 3rd person game someday. This series opens up many opportunities. Thanks again GTGD
     
  31. haeppchen

    haeppchen

    Joined:
    Dec 7, 2012
    Posts:
    2
    Hey there,

    I love your Videos , but i get An error in the FireBlaster script:

    "NullReferenceException: Object reference not set to an instance of an object
    at FireBlaster.Update () [0x0000f] in C:\Users\*******\Documents\Mein Spielpproject\Assets\Scripts\FireBlaster.cs:4"


    But I cant see where the error is. The Script is exactly like yours.

    using UnityEngine;
    using System.Collections;


    /// <summary>
    /// Fire blaster. Dieser Script erlaubt es ein Projectile zu Feuern
    /// </summary>

    public class FireBlaster : MonoBehaviour {

    //Variables Start __________________________

    // Das Projectile wird hiermit mit dem Injector verbunden

    public GameObject blaster;

    //quick references

    private Transform MyTransform;

    private Transform CameraHeadTransform;

    //Position der Projectile entstehung


    private Vector3 launchPosition = new Vector3();

    //Variables End ____________________________

    // Use this for initialization
    void Start () {

    MyTransform = transform;

    CameraHeadTransform = MyTransform.FindChild("CameraHeat");

    }

    // Update is called once per frame
    void Update () {

    if(Input.GetButton("FireWeapon"))

    {

    launchPosition = CameraHeadTransform.TransformPoint(0, 0, 0.2f);


    Instantiate(blaster,launchPosition,Quaternion.Euler(CameraHeadTransform.eulerAngles.x + 90,
    MyTransform.eulerAngles.y, 0));
    }
    }
    }


    The error is in the line "launchPosition = CameraHeadTransform.TransformPoint(0, 0, 0.2f);"

    I hope you can help me.
     
  32. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    You've misspelled CamerHead as CameraHeat in the Start function. Please take more care in debugging and I recommend that you don't push yourself to learn coding when you're tired. A rested mind is much better for learning quickly and avoiding trivial mistakes.
     
  33. haeppchen

    haeppchen

    Joined:
    Dec 7, 2012
    Posts:
    2
    Oh Wow sorry.

    I checked it like a million times, but yeah it was pretty late.

    Thank so much :)
     
  34. MadRobot

    MadRobot

    Joined:
    Jul 12, 2011
    Posts:
    339
    @haeppchen @GTGD

    You can use the compiler to help prevent this sort of mistake by using the following code.

    Instead of using
    Code (csharp):
    1.  
    2. myTransform.FindChild("MyComponentOrScript");
    3.  
    You can use this
    Code (csharp):
    1.  
    2. myTransform.FindChild<MyComponentOrScript>();
    3.  
    Then, if you have a spelling error such as
    Code (csharp):
    1.  
    2. myTransform.FindChild<MyComponentOrScroopt>();
    3.  
    It will throw an error in the Console before you can even run the game.
    Code (csharp):
    1.  
    2. Assets/Scripts/Sample.cs(32,38): error CS0246: The type or namespace name `MyComponentOrScroopt' could not be found. Are you missing a using directive or an assembly reference?
    3.  
    Which then tells you that the error is in the "Sample" script, on line 32, at column 38.
     
    Last edited: Dec 11, 2012
  35. TwinAndy

    TwinAndy

    Joined:
    Dec 14, 2012
    Posts:
    1
    It wont delethe itself when it hits the ground im using unity 4.0
     
  36. Sp33d

    Sp33d

    Joined:
    Dec 19, 2012
    Posts:
    4
    I love the tutorials but I'm having a problem with video 3. When I fire the projectile, it always comes out going strait at 90 degrees. What I mean by that is when I look up or down and fire, the projectile still comes out as if I was aiming strait ahead. It doesn't fire where I'm aiming. Here's a video of my problem I made:

    http://youtu.be/5kF0PPn9abY

    Is it a problem with this?:
    Code (csharp):
    1.  
    2. Instantiate(blaster,launchPosition,Quaternion.Eule  r(cameraHeadTransform.eulerAngles.x + 90,myTransform.eulerAngles.y, 0));
    3.  
    Here's all of my FireBlaster.cs:
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. /// <summary>
    5. /// Allows player to fire projectile
    6. /// </summary>
    7.  
    8. public class FireBlaster : MonoBehaviour {
    9.     //variables---------------------------------
    10.    
    11.     public GameObject blaster;
    12.    
    13.    
    14.     private Transform myTransform;
    15.    
    16.     private Transform cameraHeadTransform;
    17.    
    18.    
    19.     private Vector3 launchPosition = new Vector3();
    20.        
    21.     //Where the projectile should be intantiated
    22.    
    23.     private float fireRate = 0.2f;
    24.    
    25.     private float nextFire = 0;
    26.    
    27.    
    28.    
    29.     //------------------------------------------
    30.  
    31.     // Use this for initialization
    32.     void Start ()
    33.     {
    34.         myTransform = transform;
    35.         cameraHeadTransform = myTransform.FindChild("CameraHead");
    36.        
    37.     }
    38.    
    39.     // Update is called once per frame
    40.     void Update ()
    41.     {
    42.         if(Input.GetButton("Fire Weapon")  Time.time > nextFire)
    43.         {
    44.             nextFire = Time.time + fireRate;
    45.            
    46.             launchPosition = cameraHeadTransform.TransformPoint(0, -0.9f, 0.2f);
    47.            
    48.             Instantiate(blaster,launchPosition,Quaternion.Eule  r(cameraHeadTransform.eulerAngles.x + 90,myTransform.eulerAngles.y, 0));
    49.                                                                
    50.         }
    51.        
    52.     }
    53. }
    54.  

    No compiler errors, Unity 4.0, Windows 7 64 Bit and MonoDevelop. Thanks in advance, I've looked this over so many times and I just can't see whats wrong.

    Edit: There are some format issues that appeared when I copy-pasted this, like the space in Quaternion.Euler, which isn't actually there. I can't seem to fix this.
     
    Last edited: Dec 19, 2012
  37. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    @Sp33d, I can't see anything obviously wrong in your script but I think it's really strange that you're having that formatting error. You might want to delete that line of code and type it out again. You can also use my script from my website and see how that behaves.
     
  38. Sp33d

    Sp33d

    Joined:
    Dec 19, 2012
    Posts:
    4
    @GTGD Sorry for the delayed reply. Just retyped it, same problem. I took the line from your website (removing all the network code and team colors) for now, and it didn't work either. The weird thing is, if I switch the variables around (so it's Instantiate(blaster,launchPosition,Quaternion.Euler(cameraHeadTransform.eulerAngles.y + 90,myTransform.eulerAngles.x, 0)); )
    It will fire up/down based on which directing I'm looking on the X axis.
    So it's only a problem on/with the Y axis. Is there something I should change in Unity so it reads which way I'm looking on the Y axis?
     
  39. Sp33d

    Sp33d

    Joined:
    Dec 19, 2012
    Posts:
    4
    For clarity, I will word that better-
    If I change the code to this :

    Instantiate(blaster,launchPosition,Quaternion.Euler(cameraHeadTransform.eulerAngles.y + 90,myTransform.eulerAngles.x, 0));

    It will work as the code specifies, shooting based on where I am looking on the X axis. So when I look left/right, it will shoot up and down accordingly.
    However, when I simply switch the variables to where they're supposed to be,

    Instantiate(blaster,launchPosition,Quaternion.Euler(cameraHeadTransform.eulerAngles.x + 90,myTransform.eulerAngles.y, 0));

    It will only let me shoot strait ahead, like in the video I posted above.
    Is there something I need to change in Unity to make it read where I'm looking on the Y axis properly?
    Any solution? Thank you for the help and tutorials :). I can't find any solution to this, I have been looking for hours.
     
  40. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    @Sp33d I haven't been able to figure out why you're having this problem. Use my FireBlaster script for video 3 directly. Don't use the script from a later video. I have all of the scripts up on my website video by video.
     
  41. Sp33d

    Sp33d

    Joined:
    Dec 19, 2012
    Posts:
    4
    Still doesn't work D:
    Tried on a different computer, same problem.
    I honestly have no idea at this point, I might as well rebuild the entire project.
    Thanks for the help anyway,
    -Sp33d
     
  42. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    Have you tried changing the axis around. You obviously don't need to re-build, you have to debug.
     
  43. hike1

    hike1

    Joined:
    Sep 6, 2009
    Posts:
    401
    Great job on this, you solved a lot of mysteries


    On tutorial 28 Water

    When I changed the shaders for the bottom 3 'old cards, etc.', the water turned pink, so
    I just left it at the 1st one.


    Any tips on getting this water thing to work on a plain old Character Controller?

    Assets/Scripts/Water/WaterBehaviour.cs(68,25): error CS0246: The type or namespace name `PlayerStats' could not be found. Are you missing a using directive or an assembly reference?

    PlayerStats statScript = gManager.GetComponent<PlayerStats>();

    normalSpeed = statScript.maxSpeed;
     
  44. PeterGriffin

    PeterGriffin

    Joined:
    Dec 3, 2012
    Posts:
    4
    why not use Network.OnSerializeNetworkView to sync the variables and playerdatabase and also for movement...???? is [RPC] more efficient?

    I read on the documentation that

    so if ur standing still its not sending anything.Isnt that same with ur rpc movement script.

    also whats the difference between RPC buffered and not buffered? what does buffer do exactly?

    thx cheers.
     
    Last edited: Jan 15, 2013
  45. pauloaguiar

    pauloaguiar

    Joined:
    May 13, 2009
    Posts:
    700
    I have a question.

    Needs of files from series 1? Or would be series 2 you'll be done from scratch?
     
  46. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    @hike1, No the water system I've implemented won't really work with the original character controller. You'll notice that I've attached other scripts and changed the character controller. I recommend you download the Unity Island demo as that might be more what you're after.

    @PeterGriffin, that's just another way to send info over the network though I think it's dependent on the send rate. RPCs can fire anytime and give you a lot of control. I do explain RPCs and buffered RPCs in my tutorials but in short a buffered RPC is an instruction that was sent across the network and is kept by the computer that sent it for new players that will join the game. So if I'm lazy and don't want to bother storing every bit of info in a list or dictionary that is then relayed from the server to new players, I can instead use buffered RPCs and those instructions will be played out on the newly connected player's computer. It's not so good when they are tons of buffered RPCs because it will take quite a few seconds for the RPCs to play out if the connection is a bit slow.

    @pauloaguiar, yes the files from series 1 will be important for series 2 as I'm just continuing on with the series 1 project. My current intention is to keep going with this project until some year it is complete and reasonably professional (for a solo developer).

     
  47. RetnuhStudio

    RetnuhStudio

    Joined:
    Jan 4, 2013
    Posts:
    28
    Hey

    Just like to say this is a really helpful tutorial series and its really easy to follow.
    But I am up to video 7 and for some reason the first character to spawn into the server is invisible but if I kill them with another client and they re-spawn, they become visible again.

    Any Ideas on what might be causing this?

    Thanks
    Matt
     
  48. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    That sounds pretty strange. Do any errors come up in the console when you play as a server or player in the Unity editor? Try plugging in my scripts in place of yours and see if that makes a difference.

     
  49. Augustoandretta

    Augustoandretta

    Joined:
    Sep 18, 2012
    Posts:
    8
    Hello GTG , hey what the max numbers of players in the game with 2mb internet? and if i have 100 mb internet i can make connect 100 players at same time? Sorry for my English
     
  50. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    I haven't tested that with my project so I don't actually know. It really depends how heavy your game is in using network code, mine is pretty heavy, and could use some improvement, so I don't think I could support more than 20 players at the moment. If you implement the network code in an efficient manner then you'll be able to have more players playing in the same game.