Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    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. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    No I don't see your animation script affecting the player name. The error appears to be pointing to the PlayerName script, it's also telling you which lines to check. Most likely you've misspelled something and so now it can't be found.

     
  2. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    hey happy holidays!

    thanks for the 75% off sale!

    guys gals if you have not checked it out yet, don't miss out!

    until December 8th this amazing tutorial series is just $19.99, that is 75% off off the regular price!

    http://www.gamertogamedeveloper.com/store

    if you have not watched it go watch it you will not regret a single minute of your time dedicated to it

    also if you've watched it and never help contributed, don't just be a moocher, get it now at 75%

    hopefully the author will find the time to finish Gamer To Game Developer Multiplayer Video Tutorial Series 2!
     
    Last edited: Dec 5, 2013
  3. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    oh one thing please post md5 for the files at your site/here

    cause if you've ever tried to download them even with download manager its constant errors in them especially the 10gb one

    so md5 i could set the download manager to automatically repeatedly retry the download each times it fails to match md5
     
  4. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    Thanks for the feedback. That's quite worrying to me that even with the download manager the download was still breaking. I'm going to do a test download overnight and see how it turns out. Was the ZIP file just plain corrupted or were there some broken files? Is there any particular md5 file integrity checker you can recommend?

    Edit:
    Ok I've downloaded the package successfully using the download manager and I was able to unzip it with no problems. I've tried out a couple of the files and no problems. im, your internet must be even worse than mine :eek: because mine drops out every now and then and my speed is a bit below ADSL 1 speeds (my house is a bit far from the exchange). Anyway please do tell me about a decent md5 software that you've used.

     
    Last edited: Dec 5, 2013
  5. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    i get handful of files in 10gb no matter how many times i download that crc does not match per latest 7zip

    i have very fast fios which is most likely the problem... you see i had slow fios and it was solid but then they increased the speeds but then the problems started. nothing that we can do... nothing that they will do... so it happens to me all the time the bigger the file the more chances ill be getting it over and over and over again. see my posts begging people to post md5 each time unity comes out. cause i can download it in a nano second but it will take million attempts ;)

    here is md5 utility i use
    http://raylin.wordpress.com/downloads/md5-sha-1-checksum-utility/

    here is download manager i use with firefox which does md5 checking and keeps retrying automatically until it matches
    http://raylin.wordpress.com/downloads/md5-sha-1-checksum-utility/

    so please post md5 here and at the store page where downloads are for both free and paid

    also keep in mind for paid they only let you have access to page for a certain number of days and worse they limit the number of times you can access the page...

    luckily it does not look like they limit the number of times you can try to download the files, cause i easily downloaded the 10gb 10 times and i still have not gotten a clean one

    what i did is take the one with the least bad files one and extract it and then hunted the other attempts for those files without error... real pain..

    i normally go to download.com to get my free utilities i look for ones that are free and that dont have anything else in them that i dont like and i dont use their download manager so i use the direct link they also give to download the stuff...
     
    Last edited: Dec 6, 2013
  6. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    Here's the md5 hash for the zipped folder 564BFB346742C57408300FAEB72A295E

    I hope it works, let me know how it goes. Also if your download expires your download page will say so and there will be a link to send me an email to request a new download link. Unfortunately I couldn't find an option to simply provide links that don't expire.

     
  7. leekinon

    leekinon

    Joined:
    Dec 4, 2013
    Posts:
    21
    Thank you for your help! It's work!

    But there are two question I want to ask...

    1.How to make the player freeze some time when hit by blaster?
    2.How to change the speed of blaster?
     
  8. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    Ok thanks!

    I assume the above md5 is for the 10gb file.

    I'm getting it with FireFox add-on DownThemAll!. basically when FireFox tries to download something i will give you option for DownThemAll! and it asks for download folder and md5 then it tries to repeated download it until the md5 of the file it downloaded matches the md5 that you specified.

    Needless to say it can take a bit of time and use up quite a bit of bandwidth since each attempt it has to download completely the download before knowing if its good or bad.

    What Web servers / browsers should implement is something like with had in the old modem dayz where there was zmodem, xmodem and ymodem and it sent down a sliding windows of packets that could be individually checked and if one failed it could request for it to be sent again until too many retries or it suceeded! That would actually work great for the web too. It would be very easy to do since the source code for those protocols are easily be found. the thing is both the server and the client would have to have them. Still it would not be hard for someone to create a plugin for all major servrs and browsers that supported one of those protocol. I think zmodem was the best if i recall then ymodem and then xmodem...
     
  9. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    @leekinon, Currently I use the cursor control script to freeze the player when they are accessing the menu. Maybe you could extend that concept.
    You will find a variable for changing the speed of the blaster in the blaster script.

    @im, yes the md5 is for the 10gb file. Maybe you should try the download manager that I recommended because that does protect the download when the internet connection is choppy.

     
  10. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    ok cause the one i have tried it 5 times without success :(

    also the videos are excellent, extremely comprehensive and professionally made. you masterfully walk watchers step by step over just about every aspect of creating a working multiplayer. no doubt that you would make a great teacher... i highly recommend this asset to everyone. too bad its not in asset store it would easily be 5/5, just amazing!
     
    Last edited: Dec 8, 2013
  11. leekinon

    leekinon

    Joined:
    Dec 4, 2013
    Posts:
    21
    Thank a lots! Sorry to ask so many question, but there are one question just make me crazy!

    How to rotate the blaster with Instantiate?

    Because my blaster model is not in correct rotation.So,I try use transform.eulerAngles, transform.rotataion, transform.Rotate or Quaternion.AngleAxis to rotate the blaster. They can work for rotate the blaster but the blaster just not go to forward and fly to the sky!

    Moreover, I am so weak in making effect. How to make ice or wind effect in unity? I can't find related tutorial in internet.
     
    Last edited: Dec 8, 2013
  12. zoot686

    zoot686

    Joined:
    Aug 13, 2013
    Posts:
    10
    just thought I'd post to let you know that, with your tutorial package on sale as it was, I bought it, and look forward to the transformation between capsules and actual player avatars.

    Thanks much there GTGD
     
  13. leekinon

    leekinon

    Joined:
    Dec 4, 2013
    Posts:
    21
    OK, I was just solved the rotation problem. But there are one more question I want to ask. How to fix the player name after respawn? It will change the player name with some numbers after respawn!
     
  14. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    Thanks im

    Thanks for purchasing the package zoot686 and I hope you find it beneficial :D.

    leekinon, remember that the name is getting saved to PlayerPrefs and is then getting retrieved from PlayerPrefs when the player respawns. To avoid having two players with the same name the game will give the respawned palyer a random number as a name otherwise it would have been the same name as whatever you gave the last player, and that test client is still connected to the server. You only see this happen when testing. With multiple computers there's no problem because each one stores it's own PlayerPrefs and there's no issue of PlayerPrefs getting overwritten.

     
  15. leekinon

    leekinon

    Joined:
    Dec 4, 2013
    Posts:
    21
    OK.........Thank a lots! I hope this will be my last question.........

    I just try to create enemy but there is a big problem. There are no error show in unity but the enemy can't chase the player after player spawn!



    Here is my enemy script
    Code (csharp):
    1. var distance;
    2. var target:Transform;
    3. var lookAtDistance=25.0;
    4. var attackrange=1;
    5. var chaserange=15.0;
    6. var movespeed=2.0;
    7. var damping=6.0;
    8. var controller:CharacterController;
    9. var gravity: float=20.0;
    10. private var MoveDirection:Vector3=Vector3.zero;
    11. var attackRepeatTime=1;
    12. private var attackTime:float;
    13. private var myTransform:Transform;
    14. private var team:String;
    15.  
    16.  
    17. function Start()
    18. {
    19.     attackTime=Time.time;
    20.     myTransform=transform;
    21. }
    22.  
    23. function Update()
    24. {
    25.  
    26.         distance=Vector3.Distance(target.position, transform.position);
    27.  
    28.  
    29.  
    30.        
    31.         if(distance<lookAtDistance)
    32.         {
    33.             lookAt();
    34.         }
    35.         if(distance>lookAtDistance)
    36.         {
    37.         }
    38.        
    39.    
    40.         if (distance<attackrange)
    41.         {
    42.             attack();
    43.         }
    44.        
    45.          else if (distance<chaserange)
    46.         {
    47.             chase();
    48.         }
    49.    
    50. }
    51.  
    52. function lookAt()
    53. {
    54.     var rotation=Quaternion.LookRotation(target.position-transform.position);
    55.     myTransform.rotation=Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime*damping);
    56. }
    57.  
    58. function attack()
    59. {
    60.     if(Time.time>attackTime)
    61.     {
    62.     controller.animation.Play("attack");
    63.     attackTime=Time.time+attackRepeatTime;
    64.     }
    65. }
    66.  
    67. function chase()
    68. {
    69.     moveDirection=transform.forward;
    70.     moveDirection*= movespeed;
    71.     moveDirection.y-=gravity*Time.deltaTime;
    72.     controller.animation.Play("walk");
    73.     myTransform.Translate(moveDirection*Time.deltaTime,Space.World);
    74. }
    Is it need to change
    Code (csharp):
    1. Network.Instantiate(redTeamPlayer,randomRedSpawn.transform.position, randomRedSpawn.transform.rotation,redTeamGroup);
    to
    Code (csharp):
    1. GameObject go =Network.Instantiate(Resources.Load("redTeamPlayer"),randomRedSpawn.transform.position, randomRedSpawn.transform.rotation,redTeamGroup); as GameObject;
    Code (csharp):
    1. RedTeamTrigger=GameObject.Find("redTeamPlayer")
    OR something....
    Code (csharp):
    1. Resources.FindObjectsOfTypeAll
    OR it is related to some network function?

    I try many method but the error just increase>.<
     
    Last edited: Dec 10, 2013
  16. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    @leekinon, The problem is exactly what the error log is saying. You haven't told the script who the target is! You need to assign a transform for target otherwise how else will the script know what transform to chase and attack. Don't forget that you may have to do this across the network as well because the other instances of this enemy may need to know who the target is as well. If you aren't doing this across all the game instances then you must at least carry this out on the server and update the enemy movement and whatever effects you have across the network and then apply damage etc. across the network.
     
  17. leekinon

    leekinon

    Joined:
    Dec 4, 2013
    Posts:
    21
    Oh! There are a problem in network destroy. When I destroy the enemy, it output the error..........
    Error:
    Code (csharp):
    1. View ID AllocatedID: 55 not found during lookup. Strange behaviour may occur
    Code (csharp):
    1. Couldn't perform remote Network.Destroy because the network view 'AllocatedID: 55' could not be located.
    Code (csharp):
    1. if(Physics.Raycast(myTransform.position,myTransform.forward, out hit, range)
    2.             expended==false)
    3.         {
    4.             if(hit.transform.tag=="Floor")
    5.             {
    6.                 expended=true;
    7.                 Instantiate(blasterExplosion,hit.point,Quaternion.identity);
    8.                 Destroy(myTransform.gameObject);
    9.             }
    10.             if(hit.transform.tag=="enemy")
    11.             {
    12.                 expended=true;
    13.                 Instantiate(blasterExplosion,hit.point,Quaternion.identity);
    14.                 Network.Destroy(hit.transform.gameObject);
    15.             }
    16. .........
    17.  
    Is it related to RemoveRPCs? I just don't know how it's work......
    Sorry to ask so many question.........because the network codes are so different from normal.
     
  18. MithosKuu

    MithosKuu

    Joined:
    May 12, 2010
    Posts:
    34
    I am on episode 5, when a new player joins everyones camera snaps to them, every player retains full control of their character, they are just being forced to essentially screen watch. My camera script is checking for networkView as per the video so I assume it has something to do with how my cameras are set up in the editor, but nothing I have tried has fixed it.
     
    Last edited: Dec 12, 2013
  19. Nims

    Nims

    Joined:
    Nov 11, 2013
    Posts:
    86
    Thanks for this great series of tutorials. I am following them slowly, trying to understand what you did in each step.
    I have reached chapter 14 and have encountered a problem, regarding the block placement by the server. If a situation arises where different player game-objects on server receive an RPC to tell the server to place a block at the same time, then they will be changing the dropPosition, dropRotation and dropSignal simultaneously. How is this solved?
     
  20. MithosKuu

    MithosKuu

    Joined:
    May 12, 2010
    Posts:
    34
    I was able to fix my camera problem, and I've just reached the end of video 6 but my players aren't taking damage.

    Hit By Blaster is being activated but IWas Just Attacked isn't, My Health isn't decreasing, and My Attacker is being named "Spawn" instead of the attacking player's name, which I suspect might be the root of the issue, but I compared my Health and Damage script and Blaster script with the examples and they are identical.
     
  21. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    hi i was thinking of how you could drive your sales of this video tutorial series so you can have more money/incentive to work on series 2

    make available as a starter kit in unity asset store the game you've created in the tutorial.

    basically $30 with details on how to get the tutorials directly from you for an additional $50

    that gets you the $80 that you want.. and you can discount from there...

    basically what you have right now is one of the best starter kits for indie game developers

    you give just about everything someone needs to get started on whatever game they are thinking of creating.

    all the screens are there right now to easily put together a multiplayer game.

    other starter kits with less functionality sell for even higher.

    please consider. i think you are missing out bigtime on sales also just putting it here in teaching where nobody sees it..

    i dont think steam will carry it anytime cause its not for their source engine. but unity store will and it will be targeted at unity customers which is what your starter kit and video tutorials is right on the target for...

    so think about it... it dont hurt. it costs nothing. unity store takes 30% and so does steam store

    also if its selling you can talk to unity about letting you have space for 10gb tutorials in their asset store. i bet they would love to have your tutorials its the most complete, easiest to follow, you take developers step by step from scratch to a fully working game loaded with features.

    and if you can do series 2/3/4 it will be even better deal for unity. its way a head of anything they have in tutorial section. they should buy you out... / hire you to do their tutorials...

    anyways i hope you will consider this post. ive thought about it, if you dont want to do it, dont have the time, dont care, let someone else do it for you. you can work out an arrangement. the source code is well worth $50-$100 starter kit as is... look at other starter kits.

    you will just have to roll in some of things you do in series 2 to for example handle unity networking...

    anyways just think about it. and if anyone from unity around, take a look at this authors stuff it would really be great if you carried it and he were not like limited to teaching section where i bet its being mostly ignored...

    also dont give your tutorials all for free, have a couple for free and make them buy it. hey if they want to learn they have to pay something. making these things at this professional level of quality is not cheap. surely worth $50-$100, it not like there is anything even close to these...
     
  22. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    @leekinon, I don't recommend using Network.Destroy until you really have to because your enemy gameobject has probably been sending out RPCs and there will be probably be incoming RPCs to it as well. My rough guess on what is happening in your setup is that the enemy has been destroyed across the network but there are some RPCs that still haven't reached it. By the time the RPCs arrive that unique Netowrk object which has an Allocated ID of 55 has already been destroyed and so now there is an error. That is my guess. My recommendation would be that you make use of the style I've implemented in the HealthAndDamage script because that way the networked gameobject is cleanly removed across the network using an RPC instead of the inbuilt Network.Destroy.

    @Nims, you could run further validation code on the server end. You remember that when the player is placing the block a rough check is performed to see if there is already a block there? If a block is already there then of course you can't place a new block in the same place. In the same way you could alter the Server code to perform the same type of check. So if two players happen to place blocks at the same time in the same place the instructions will reach the server and the server will place a block for the instruction that arrives first. The second instruction will be telling the server to place a block at the same place but you could modify the code so that the server does the same sort of validation before placing the block. So if the server just placed a block it will ignore the other instruction and not place a second block in the same place. I hope I answered your question.

    @MthosKuu, This sort of problem has happened to other viewers too and sometimes it's because something is misspelled somewhere or something that should be upper case is lowercase instead e.g. onConnectedToServer (wrong) vs. OnConnectedToServer (right). I'm not sure how the attacker is getting named Spawn though, maybe double check that your tags are correct on the player prefabs and spawn points. Your suspicion is correct in that because the attacker name is wrong the HealthAndDamage script is unable to validate the attack and so no damage is applied. You'll need to check your PlayerDatabase script as well maybe something is wrong there and the player's name is not getting stored in the PlayerList. Write some code using debug.log to check what is in the list as clients spawn into the game.

     
    Last edited: Dec 16, 2013
  23. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    in video 8 you cover AssignHealth script which uses a

    yield return new WaitForSeconds(waitTime);

    to sort of wait for the buffered rpc calls to play themselves out before updating the health

    well as you mentioned in the video it does not quite work out so good. there is unnatural delay for fast connections with few rpc calls and not enough of a delay for slow connections with lots of buffered rpcs calls

    you mentioned having a like loading screen to sort of mask it and i have added that

    but that too just masks the problem. is there a way to know when buffered rpc calls have finished playing out. is there some api that i can call and check

    if not what other way can i handle this...

    thanks in advance...
     
  24. Nims

    Nims

    Joined:
    Nov 11, 2013
    Posts:
    86
    You misunderstood my question..let me try again.
    If different player type gameObjects (Red/Blue players) on the server itself, all try to tell the server to place a block at almost the same time then:
    PlayerObject 1: will ask to place a block at position1, rotation 1.
    At the same time/or very soon afterwards PlayerObject 2 on the server will be asking to place a block at a different position: position 2, rotation 2.
    Say PlayerObject 1 has set these parameters already, but the dropSignal has not yet been reset to false, and at this time PlayerObject 2 will be setting new values for position and rotation. This will result in PlayerObject request to place a cube to be overridden by PlayerObject 2 request because they were close enough in time.
    The more players you have the bigger chance this will happen.
    Would you not need a list type solution for this?
     
  25. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    since author out to lunch ;)

    and im bored

    i think he said you can do some server checking to handle such a case and have server code determine what to do

    for example 1st one places block, next one does not get to place block since there is block there already.

    so that server can determine who when a blocked is placed

    so what then happens is client told who get their blocked placed and who did not

    that again can be server code passing back stuff to clients

    in such a case so server code will need to return to client your block request passed or your block request failed if that is important to client

    for example if passed means resources are reduced playerName.playerName for player able to place block and if a player is unable to place block resources are not reduced and some some fail to place block sound is played.

    or if it doesnt matter the client but if clients will have to render the correct team block for the player or tem. let say red team did red block and blue team did blue block...

    then server must tell client so it will know what to do...

    so if server determined whose block and its important to client to know then you need to send back and rpc to everyone player n block won... or team n block got placed...

    sort of ack/nak...

    perhaps rpc is not best for this. i would have done it like client/server i/o streams. if such a thing was supported..


    but in general...

    if u r sending rpc calls they should do them in the ordered received.

    so there is never really a chance of at the same time, someones packet will be 1st...

    someone request will be 1st...

    what you need is if some server logic to check am i already putting one for someone else but that is only if your code is natively multithreading, which it by default is not...

    so you can assume that the request being handled 1st came 1st and the one being handled 2nd came 2nd

    but if you want to order them sounds like u need a fifo queue (sort of list)

    http://en.wikipedia.org/wiki/FIFO

    or if you are doing native multithreading then you can just use some semaphore and lock. basically have a flag saying someone if adding a block at some location and radius everyone else blocks if in that radius

    still easier to have producer consumer since you dont have to block and you just have some queue with all the request and some consumer(s) eating them...

    but for unity since its not natively multithreading game logic , unless yo uspecific do it i dont think you have to worry about it... unless you doing like coroutines/yields...

    i am assuming it will all be handled in a single pass through update...

    so its sort of atomic to update

    i hope i made sense... and that author does not say im all wrong...
     
    Last edited: Dec 17, 2013
  26. Nims

    Nims

    Joined:
    Nov 11, 2013
    Posts:
    86
    This was definitely the answer i was looking for. Thank you.
    During a single pass through the update functions of different script being employed..i understand this is done sequentially and not concurrently?
    I will have to investigate further the subject of multithreading in Unity.
    As I come from a Java background - are semaphores and locks the C# solution for managing synchronization across different threads?
     
    Last edited: Dec 17, 2013
  27. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    and i thought you were going to report me as some nut and have me banned ;)

    glad i could sort of help. i sort of ramble cause its very late when im here its like well past 4 am est and so tired...

    re: java/c#

    i too come from java / c# background...

    re: synchronized/lock

    yeap
    check this out.
    http://tutorials.csharp-online.net/...nce_between_CSharp_lock_and_Java_synchronized

    there are many sites that have on one side java on the other c# there is also a very good book but i forget, but look it up at amazon...

    but unless you yourself are explicitly doing native threading ,which you are most likely not, you dont have to worry about it

    all the code is purely single threaded. so there is no need to synchronize that i know of

    and if you were to do c# native threading then you have the difficulty that unity api are not thread safe so you have added complexity of dealing with it...

    it just looks chaotic cause game engines and the way the game logic is done its very old style of writing code, sort of spaghetti coding by design.

    so basically they have like message loop and they going through a queue and making calls, the only thing is you dont control the order any game object can have lets say update method and who knows which object update is called first and which object update second... but they are not called at the same time!

    so its more like

    foreach(gameobject gobject in gameobjects)
    {
    gameobject.update()
    }

    see not multithreading

    the thing is you get request to put block you have server check if it determines it can put block it has to tell everybody i put this players block

    then it gets request to put block you have server check if it determins that it cant put block it has to tell everybody i cannot put player x block

    ok perhaps that is wrong. it may have to just tell playeer x i coul dnot put your block

    but if for example you have to play sound of failure then u have to tell everbody if you want everybody to here sound

    if its ok for just player x to be told then just tell player x

    if nobody really needs to know of failure then save the rpc call...

    keep in mind rpc calls are very expensive... so dont make more than u need to

    and dont buffer any u dont need to

    i so wish this author did series 2/3 cause it would all be so much better done for unity networking and things like being closer to real game with mecanim, ect... fully explained/intergrated into this framework...
     
    Last edited: Dec 17, 2013
  28. Nims

    Nims

    Joined:
    Nov 11, 2013
    Posts:
    86
    Thanks again,
    I was wondering why there was a need to split the block placement to a foundation layer and a construction layer in the first place?
     
  29. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    ive not gotten that far. im 2/3 into video 8... tomorrow communications window ;)
     
  30. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    Hey im, those are some really long posts :). Yes the AssignHealth business is pretty sloppy code. My intention for series 2 was to expand the PlayerList to include player health and so when a new player joins the game, the server will go about the business of checking the health on each player and then transmitting the contents of the PlayerList to the new player or just the health values. That way I wouldn't need pointless RPCs though the information sent to the new player would be slightly out of date by the time it gets to them. I figured that wouldn't be too much of an issue because health values are naturally a little out of sync across the network anyways and players are going to get blown up sooner or later and have to respawn.

    Thanks for the sincere advice. I have to keep series 2 on hold because I'm well into developing my RPG game and at my current progress rate I hope to have a nice playable prototype by mid next year that will demonstrate how the game will look and feel and convey what the story is about :D. I don't have enough free time to work on two project simultaneously otherwise I would not have let Series 2 slide.


    Hi Nims, yes a list would work for housing information on blocks for the server to create. I use a list for block removal so that multiple blocks can be removed at the same time when a rocket strikes a set of blocks. If somehow the command from two players came in exactly the same frame then I think that is when one command might get overwritten, but the chance of that I think is minuscule enough to not be worried about it.

     
  31. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    i love / excel at walls of text ;)

    re: my rpc game

    so where is link to your game so we can check it out :)

    re: Thanks for the sincere advice

    np, but i was not trying to give you any advice, only throw some ideas at you...
     
    Last edited: Dec 18, 2013
  32. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    in video 8 communications window im having a little problem even though code is matching

    when i press t i get a t showing up in the textbox that i have to delete

    any idea why t is showing up. shouldnt it had eating the key when it did Input.GetButtonDown(). an anyways when i press the t to bring up the text box the textfield does not have focus at that point only later, so why it it getting in the text field

    is it because im using latest unity... that would be sad...

    please advice

    ==================
    ok update

    i was able to sort of work around it by switching fro Input.KeyButtonDown() to InputKeyButtonUp()

    so what gives...
     
    Last edited: Dec 18, 2013
  33. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    Yes it's because you're using a new version of Unity, but you can watch my second video of series 2 to understand what you need to do.

    No links to my in development RPG game yet. Once the prototype is ready then I'll be able to do a show and tell. I'm slowly building each required system and I'm also writing the story as well.

     
  34. Nims

    Nims

    Joined:
    Nov 11, 2013
    Posts:
    86
    @im - Check out the S2.2 Video on updating the project to Unity 4. - there is some info about fixing the deprecated methods used in communication implementation and it seems to solve the t showing up too.
     
  35. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    thank you both and happy holidays!

    i cant wait to see what rpg game you cook up...
     
    Last edited: Dec 18, 2013
  36. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    in video 9 you mention some bug / limitation having to do with the fact that players are destroyed, including their rpcs, when they are killed and thus will not show up on like the scoreboard until they respawn because the code is not always using the player database and instead relies on rpcs.

    so i guess at some point i'll have to change it to use the player database and not have these kind of issues

    but i was also wondering why are you deleting the player when all they are is dying. couldn't you just as well set a flag, killed and not have him displaying until he respawns and then all you have to do is make him visible again, clear the flag and change the position/rotation to the new spawn position/rotation?

    knowing the rest of your videos and the functionality that you implement do you see me running into problem later on changing it so that when a player dies they are not destroyed, but hidden until they respawn. that would some some problems like having to wait for health on spawn since their rpc would always be running and the players are really always there until they disconnect. so new players would get their buffered rpc with their health.

    i guess eventually i would want things like health coming from the player database and so new players joining would not have to wait while it plays out updating healths.

    anyways what do you think...


    also just noticed scoreboard does not handle long lists with scrolling like communications log... so i will have to make some changes, borrow some code from how you did scrolling for communication log... hopefully that will work...
     
    Last edited: Dec 19, 2013
  37. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    You are 200% correct. Just disabling the player is a superior option and you can still delete their RPCs while you're doing that. From memory I don't think you will run into a problem with future videos. Your respawn will be different though in that you'll have to make new functions for handling the reactivation of the player instead of their instantiation. What I was demonstrating though was how to remove a network object cleanly without relying On Network.Destroy which can be quite tricky if the Network IDs haven't been manually allocated or some such thing.

    A player database I believe is the way to go especially to get away from buffered RPCs. I think even my block placements which come in video 14 also use buffered RPCs which is slow so a database would have been a superior implementation for that as well. Buffered RPCs are nice though in that there's basically no thinking required in their implementation and stuff just works :).



     
  38. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    ok great im just confused by this part

    "and you can still delete their RPCs while you're doing that. "

    why would i want to delete their rpcs, wouldnt i want them to continue to send/receive rpcs while killed, but invisible.

    i think when i move to playerdatabase and as you mention in future switching to server databases all the buffered rpc stufff can be removed and when player joins they just go to client

    is this correct or is buffered rpcs still needed...

    also for player database i was thinking of replacing the list with a map, cause searching through lists is on average O(n/2) and map is on average O(1)

    and i most likely will have enemy map for npc stats as well which could end up with hundreds of npcs that server would have to track.

    anyways for player its not too big of a deal, since im expecting to only have a handful of players, but in mmo it could be in hundreds, thousands, or even tens of thousands and that would require a bit of searching if its a list...
     
  39. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    You won't need to delete RPCs if you don't have buffered RPCs, but if you did have buffered RPCs coming from the players then it is a good idea to clear them up so there isn't a massive back log for new players.
     
  40. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    oh ok thanks, as you can see im new to this whole unity/buffered rpc thing. the api looks like a bit limited, like i could not find an api to check the length of the buffer so that i could see if anything was buffered/pending... at the originator or even at the destination client..
     
  41. Puzzled-Panther

    Puzzled-Panther

    Joined:
    Dec 23, 2013
    Posts:
    1
    Just finished the 1.6 episode for the third time.
    Why?.. because damage doesn't register... even though there are no errors and I've double checked all the code for the 1.5 and 1.6 episodes.
    Everything works as intended but damage doesn't register on the players.
    The "Hit By Blaster" lights up so does the "IWas Just Attacked" and "My Attacker"... but no damage registers.
    Code seems fine.

    Please halp :(

    EDIT:
    Finally found it!

    should have been:
    networkView.RPC ("UpdateMyCurrentHealthEverywhere", RPCMode.Others, myHealth);

    was:
    networkView.RPC ("UpdatemyCurrentHealthEverywhere", RPCMode.Others, myHealth);

    Didn't show up as an error... missed it so many times (was looking for around 3 hours)
    Not sure whether to celebrate or shoot myself Oo
     
    Last edited: Dec 23, 2013
  42. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    hey happy holiday!

    replacing all the buffered stuff with new fields in playerdataclass that get updated and then when someone joins they get the player list and from there update the local values

    also i was thinking as we posted about redoing death/respawn

    and perhaps reducing the number of rpc calls so its less chatting. basically moving more to player list and locally directly access and update ones playerdataclass so their are not like local variables all over the place but a references to onces playerdataclass

    anyways just my thought... sorry for all the changes to your excellent work i suffer from a very bad case of "not invented here syndrome" a long suffering incurable mental illness where one has an uncontrollable urge, need to change the work others do for some unexplainable reason, nothing personal...
     
    Last edited: Dec 27, 2013
  43. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    431
    Happy holidays to you too! Mate, do whatever you feel like to make the scripts better. All I did was give some sort of foundation and from there everyone is free to do as they like with the scripts.

     
  44. Lord-Ayush

    Lord-Ayush

    Joined:
    Oct 26, 2012
    Posts:
    2
    Hey !
    I need Help ! I have E-mailed U , Sent a Private Message and mailed on youtube !

    Got No reply till now !! :(

    Plzz reply to my messages !!

    Happy New Year !!
     
  45. FAR

    FAR

    Joined:
    Jan 13, 2014
    Posts:
    3
    Sir
    1. What should i do if i want more that 1 camera on the a player ( I want Left,Forward, Right and TopDown for minimap)
    Is it Just add a Child object to the existing Camera and the define them there ??
    2. I like to have different type of players with different camera setup and different skills
    Do i build new player type and when i Join the game i just select the type of player i want to be ??


    Regards
    Frank
     
    Last edited: Jan 14, 2014
  46. MithosKuu

    MithosKuu

    Joined:
    May 12, 2010
    Posts:
    34
    I'm really loving this tutorial series, it is seriously one of the best learning packages I have come across.

    I am only up to video 9 so I don't know if any of this is addressed in later videos or this thread, but there are three distinct pieces of feedback I would like to offer in hopes of making it even better.

    Text issues:
    There are currently no limits to the size of player names, messages, or the message history, outside of a 4096 character hard limit imposed by RPC's, in addition, the chat history has no limit, meaning it will continue to fill and take up memory for the duration of the server. These shouldn't be too hard to fix, just seems weird that they were overlooked, especially when a limit was placed on the size of the combat log.

    Server security:
    Handling everything client-side may help reduce lag, but it also makes it easy to cheat, for instance an unscrupulous player could use third party programs to tell the server that they dealt 10,000 damage to all enemy players at once . Switching things around so that clients only sent the server button input, with the server deciding what happens would be a lot more secure.

    Expandability:
    This series sets up a great basis for a multiplayer map but it seems like adding multiple maps would be really hard. An idea solution would be to create a main menu scene to handle most of the create/join server code, with the actual joined server/gameplay code in the multiplayer maps.

    Seriously man, keep up the great work, and congrats on making it through Steam Greenlight!
     
  47. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    hi i may have found a bug

    water behavior script changes the character motor maximum fall speed from 20 to 2

    that appears to cause problems with the fall damage script when you teleport into the air and fall down when you hit the ground it calculates fall damage as a negative! so it actually adds more to your health!

    the problem is that in fall damange script the hurt velosity is still a -15 so

    damage ratio will be negative!

    like -8.461

    which will result in negative fall damage!

    and when u subtract the negative fall damage from the player heath you actually end up increasing it often well above the maximum player health!

    so how can water behavior, character motor and fall damage be adjusted so it still works as expected for moving in water, but when u teleport up into the air from underwater or in the water (cause it also happens if u r just standing in water) it will calculate fall damage correctly when u fall back down into the water.

    thanks in advance!
     
  48. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
  49. GregMeach

    GregMeach

    Joined:
    Dec 5, 2012
    Posts:
    249
    Missed the GreenLight but congrats!!!

    Oh and good luck with the kickstarter.... ;) ;)
     
  50. radar089

    radar089

    Joined:
    Jan 2, 2014
    Posts:
    216
    Is this up to date for unity 4? when i tried to build it i got a ton of console errors. also when i followed the first scripting tutorial i didnt get the same drop down box options when i was in mono.
     
unityunity