Search Unity

[UNITY 5 FPS Tutorials] GTGD S3 - Advanced First Person Shooter

Discussion in 'Community Learning & Teaching' started by GTGD, Oct 9, 2015.

  1. Saurabh-Saralaya

    Saurabh-Saralaya

    Joined:
    Apr 28, 2016
    Posts:
    23
    Ah i completely forgot to take into regard that people wear headphones while playing :rolleyes:. But then again there is always more room for improvement of skills, and the game. Thank you for taking your time to watch the video. Cheers! :D
     
  2. Torrey

    Torrey

    Joined:
    Jan 22, 2016
    Posts:
    13
    So i actually figured out how to carry the score over from scene to scene and require a score to go to next one and have a textbox appear in a trigger i looked at your scripts and for some reason it just clicked and i was figuring it out. and put it so the right answers of question make you get points. wrong answer or restarting you lose points. I still have not messed with cursor think that will be a tomorrow thing hopefully i can get it. Thanks for the help. i like having the cursor locked in game play but when i need to answer the questions its still locked and can not click the buttons. i am still a bit lost on how to do it maybe i will figure it out but thank you.
     
  3. MattyPhatty2x4

    MattyPhatty2x4

    Joined:
    Jan 3, 2015
    Posts:
    1
    Distracting Item Script.

    GTGD thank you so much for this set of tutorials, your teaching style is perfect and you provide such a robust system.

    I made a script below to allow for items to cause distractions to an enemy. I've been playing around with Zombie ai and thought this would be fun.

    You'll have to add a public bool characterOverride; to the Enemy_Master script and have it switch to True in the Enemy_Detection script at:

    Code (CSharp):
    1.                
    2. if (hit.transform == potentialTarget)
    3. {
    4.   enemyMaster.CallEventEnemySetNavTarget(potentialTarget);;
    5.   enemyMaster.characterOverride = true;
    6.    return true;
    7. }
    Now I've only gotten this to work if the Enemies are in the Scene at runtime, if they are instantiated it won't work and running a GameObject.FindGameObjectsWithTag("Enemy"); often would get taxing. I ran this script on a group of 100 zombies and it works great with almost no frame drop.

    Attach the below script to an item in your scene and make sure you add the above.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. namespace S3
    6. {
    7.     public class Item_MakeNoise : MonoBehaviour
    8.     {
    9.         public Transform myTransform;
    10.         private float detectRadius = 20; //distance the sound can be heard
    11.         private GameObject[] enemyList; //array of all enemies in the scene
    12.         private GameObject[] justParentEnemyList; //used to transfer only the wanted enemies and not there hit co
    13.         private int enemyCount = 0;
    14.  
    15.  
    16.         private float checkRate = 2; //check rate here is used to prevent the call from initiating during multiple collisions that occur when an object is thrown.  This cuts down on processing.
    17.         private float nextCheck;
    18.  
    19.         void Start()
    20.         {
    21.             SetInitialReferences();
    22.         }
    23.  
    24.         void OnCollisionEnter()
    25.         {
    26.             if(Time.time > nextCheck)
    27.             {
    28.                 nextCheck = Time.time + checkRate;
    29.                 StartCoroutine(zombieDistract()); //not sure if a coroutine was necessary but it works well
    30.             }
    31.         }
    32.  
    33.         void SetInitialReferences()
    34.         {
    35.             enemyList = GameObject.FindGameObjectsWithTag("Enemy"); //find all the enemies in your scene, however this also include all there hit boxes which we don't want, I added the following code to shrink the array down to remove those items.  Again there is probably a better way to do this so if anyone knows please inform me.
    36.  
    37.             for(int i = 0; i < enemyList.Length; i++)
    38.             {
    39.                 if (enemyList[i].GetComponent<NavMeshAgent>() == null) //checks if object has NavMeshAgent, which means its the parent AI item
    40.                 {
    41.                     enemyList[i] = null;//sets array value to null if no NavMeshAgent
    42.                 }
    43.                 else
    44.                 {
    45.                     enemyCount++; //increments if it is an AI enemy
    46.                 }
    47.             }
    48.  
    49.             justParentEnemyList = new GameObject[enemyCount];//sets the size of the dummy array to the amount of actual AI you have
    50.             enemyCount = 0;
    51.  
    52.             for(int i = 0; i < enemyList.Length; i++)
    53.             {
    54.                 if(enemyList[i] != null)
    55.                 {
    56.                     justParentEnemyList[enemyCount] = enemyList[i];
    57.                     enemyCount++;
    58.                 }
    59.             }
    60.             enemyList = justParentEnemyList;
    61.             myTransform = GetComponent<Transform>();
    62.         }
    63.  
    64.         IEnumerator zombieDistract()
    65.         {
    66.             for (int i = 0; i < enemyList.Length; i++)
    67.             {
    68.                 if(enemyList[I] != null) //check if element has something in it
    69.                 {
    70.                     if ((enemyList[I].transform.position - myTransform.position).sqrMagnitude < (detectRadius * detectRadius)) //check if zombie is within hearing range of object
    71.                     {
    72.                         if(enemyList[I].GetComponent<Enemy_Master>().characterOverride == false) //checks if the character has been detected, this is important because the ai will teeter between the object and the player if you don't override it.
    73.                         {
    74.                           enemyList[I].GetComponent<Enemy_Master().CallEventEnemySetNavTarget(myTransform);
    75.                           //sets the enemies location to the object
    76.                         }                
    77.                     }
    78.                 }
    79.             }    
    80.             yield return new WaitForSeconds(0.1f);
    81.         }
    82.     }
    83. }
    [/I][/I][/I][/I]
    I've had a lot of fun playing with this the past day and like I said I managed to run about a 100 ai with no problem. If anyone knows of a better way to do this I'm all ears as I want to make kind of a Zombie stealth type game and this mechanic seems useful. I'll try and post a video later but I have to leave for work soon.

    Edit 1: I didn't get far enough in the tutorials to realize that we set multiple parts of the AI to have the tag "Enemy," so I added a section in the initial references to re-size the array with only the enemies to prevent slow down in the detection loops.
     
    Last edited: May 7, 2016
  4. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Thanks this is pretty interesting. I would probably go about it in a different way. I would set a bool when the item is thrown and that bool has a time limit before it is set to false. While that bool is true and so long as the item is above a certain velocity any collision with the item will cause it cast an overlapsphere at the contact point to detect AIs. If any are present and don't have already have a target they will be told to go to the position of the disturbance
     
  5. Saurabh-Saralaya

    Saurabh-Saralaya

    Joined:
    Apr 28, 2016
    Posts:
    23
    Hey there! I'm now at Video 38 [Main Menu], and i have completed creating the Buttons, but the buttons have gone unresponsive.
    I have found out that this happens because the Hierarchy of buttons.
    i.e CanvasMainMenu > [child]Panel > [child]2Buttons

    If we remove the Panel out and add the GridLayoutGroup directly to Canvas, the button's responsiveness is retained.but I haven't fully understood the Concept behind the Buttons.

    This might be happening because the panel is placed upon the button, but i have set the buttons to be child objects itself.
    I rechecked the video but couldn't find why this happens.
     
  6. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Delete and start again and make sure EventSystem is there in the hierarchy. The purpose of panels is to house/group UI elements in a manageable way. They must be children of the panel otherwise the panel might sit on top if its arranged in that way in the heirarchy.
     
  7. Saurabh-Saralaya

    Saurabh-Saralaya

    Joined:
    Apr 28, 2016
    Posts:
    23
    I redid the MenuCanvas and it worked.:D But i'm not sure why i did not work before.
     
  8. METTO

    METTO

    Joined:
    May 3, 2016
    Posts:
    2
    Hello! Here is my assignment. And just wanted to say: As someone who hasn't coded anything in his life, your tutorials are amazing and easy to follow (even for me:D). For the last month, in addition to learning at home, I have used a lot of time listening and repeating your chapter 1 videos from my headphones at my work (I work at factory) to learn the basics of coding. To show you my support I bought the S3 from Steam. Thank you for making coding interesting!:)
     
  9. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    A+ All criteria satisfied!
    Nice accomplishment for someone who has never coded before!
     
  10. METTO

    METTO

    Joined:
    May 3, 2016
    Posts:
    2
    Thanks! Off to Chapter 2!
     
  11. Gxnx

    Gxnx

    Joined:
    May 20, 2016
    Posts:
    2
    Hello there! Here is my assignment and I hope I got everything right :) Thank you GTGD for the awesome tutorials, I'm learning a lot. Can't wait to start with the next chapter!!

     
    Saurabh-Saralaya likes this.
  12. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    A+ Fantastic Work!
    Nice touch with the text conversation!
     
  13. NPBirader

    NPBirader

    Joined:
    Feb 23, 2015
    Posts:
    20
    Here's an update video of my little work. Hope you like it.:D

     
    Saurabh-Saralaya likes this.
  14. Saurabh-Saralaya

    Saurabh-Saralaya

    Joined:
    Apr 28, 2016
    Posts:
    23
    Hello! I'm working on my project, and my whole scene lighting became dark. This happened during the unity 5.3 conversion (video 53) while we baked a new light(map?) at the end of the video. I have set up a alternate Skybox and this might be the root cause for the problem.

    Update: I re-baked the whole lighting with default skybox and it has been restored to previous lighting.
    Okay so the problem is fixed but, how do i set up a dark colored skybox with lighting that wont be way too dark wrt to the scene and its models
     
  15. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Nice implementation! I like the tree chopping! Maybe you can use the explosive barrel to bring down trees :)
     
    NPBirader and Saurabh-Saralaya like this.
  16. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    I'd recommend watching this tutorial to understand more about lighting
     
    Saurabh-Saralaya likes this.
  17. Saurabh-Saralaya

    Saurabh-Saralaya

    Joined:
    Apr 28, 2016
    Posts:
    23
    Thanks!
     
  18. Saurabh-Saralaya

    Saurabh-Saralaya

    Joined:
    Apr 28, 2016
    Posts:
    23
    Hey there!.
    I was going through Enemy Flee Script, (Video 86) and i came across a bug where the FleeTarget method returned false,
    no matter what happened, this resulted in the Enemy standing still instead of fleeing when they came below health.

    This is the Original Method:
    Code (CSharp):
    1.  bool FleeTarget(out Vector3 result)
    2.         {
    3.             directionToPlayer = myTransform.position - fleeTarget.position;
    4.             Vector3 checkPos = myTransform.position + directionToPlayer;
    5.  
    6.             if (NavMesh.SamplePosition(checkPos, out navHit, 1.0f, NavMesh.AllAreas))
    7.             {
    8.                 result = navHit.position;
    9.                 return true;
    10.             }
    11.             else
    12.             {
    13.                 result = myTransform.position;
    14.                 return false;
    15.             }
    16.         }
    I spent some time debugging and finally found the solution to this problem
    in the if statement, if we replace the 1.0f (This stands for maxDistance) with fleeRange, we can overcome the problem and the enemy will flee

    Code (CSharp):
    1.             if (NavMesh.SamplePosition(checkPos, out navHit, fleeRange, NavMesh.AllAreas))
    2.             {
    3.                 result = navHit.position;
    4.                 return true;
    5.             }
    6.             else
    7.             {
    8.                 result = myTransform.position;
    9.                 return false;
    10.                
    11.             }
    I'm not entirely sure how NavMesh.SamplePosition works but this might be a temporary fix.
     
  19. alyraptor

    alyraptor

    Joined:
    Aug 18, 2015
    Posts:
    1


    Here's my attempt.

    (Edit: I just realized that it looks as though the enemies can't push through the block walls. It's actually a matter of the walls being slightly outside of the NavMesh.)
     
  20. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    A+ Great Work!
    All features implemented, nice clean level design
     
  21. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Very good work there, yes what you're doing is to expand the area to be checked for finding a suitable place on the nav mesh to go to
     
  22. NPBirader

    NPBirader

    Joined:
    Feb 23, 2015
    Posts:
    20
    I have a question to everyone who can help me.
    In my scene i have a waterbottle with an itemwater script. My playerdetection script detects waterspots to fill the bottle if it is empty.
    When i click drink in my bottle theres no water and if i go to the spott and click fill my empty waterbottle it will be filled. The playerdetection calles an event in the waterspotmaster script. Now i want to get the itenmaster script from the waterspot_fill script. I managed to get one of the bottles with gameobject.find "waterbottle" but the other ones in the scene dont work. An if statement in my waterspot_fill script checks if the waterbottle root is the player. Now im trying to get all bottels in the scene to work. Could someone help me?
    I hope you understand what i am talking about.
     
  23. NPBirader

    NPBirader

    Joined:
    Feb 23, 2015
    Posts:
    20
    What happens with the item tag?
    Because its actually an item which you can pick up, use, fill,throw.
     
  24. Saurabh-Saralaya

    Saurabh-Saralaya

    Joined:
    Apr 28, 2016
    Posts:
    23
    I had to apply some validations int the Gun Ammo Scripts (For Reload),
    did i have to do it or did i get the default script wrong somehow?


    Code (CSharp):
    1.  void TryToReload()
    2.         {
    3.             for (int i = 0; i < ammoBox.typesOfAmmunition.Count; i++)
    4.             {
    5.                 if (ammoBox.typesOfAmmunition[i].ammoName == ammoName)
    6.                 {
    7.  
    8.                     if (ammoBox.typesOfAmmunition[i].ammoCurrentCarried > 0
    9.                         && currentAmmo != clipSize
    10.                         && !gunMaster.isReloading)
    11.                     {
    12.                         gunMaster.isReloading = true;
    13.                         gunMaster.isGunLoaded = false;
    14.                     }
    15.  
    16.                     else if (ammoBox.typesOfAmmunition[i].ammoCurrentCarried == 0 && currentAmmo == 0)
    17.                     {
    18.                         gunMaster.isGunLoaded = false;
    19.                         gunMaster.isReloading = false;
    20.                         break;
    21.                     }
    22.  
    23.                     else if (currentAmmo == clipSize)
    24.                     {
    25.                         gunMaster.isReloading = false;
    26.                         break;
    27.                     }
    28.  
    29.                     else if (ammoBox.typesOfAmmunition[i].ammoCurrentCarried == 0)
    30.                     {
    31.                         gunMaster.isReloading = false;
    32.                         break;
    33.                     }
    34.  
    35.                     if (myAnimator != null)
    36.                     {
    37.                         myAnimator.SetTrigger("Reload");
    38.  
    39.                     }
    40.                     else
    41.                     {
    42.                         StartCoroutine(ReloadWithoutAnimation());
    43.                     }
    44.  
    45.                     break;
    46.                 }      
    47.             }
    48.         }
     
  25. ShadowyXP

    ShadowyXP

    Joined:
    Aug 25, 2015
    Posts:
    1

    8 months late but i just found you yesterday.
    Can't wait to continue
    (Not nearly as good as some of the ones im browsing through, i already knew most of this stuff so i cobbled it together in about 2 and a half hours.)
     
    Saurabh-Saralaya likes this.
  26. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    How are you going with this? What Raf said sounds like a way to do that from what I understood. Please try breaking down the mechanic you are trying to achieve into simpler steps so that others reading, and also myself, can understand you better and hopefully give you more useful advice. Also doing that can sometimes make it clearer for the one writing the code how to achieve what they are trying to achieve!

    That's odd, what was happening when you didn't add those if statements? The if statement, prior to the else if's should have captured all of those conditions. Here's my code for you to test out

    Code (CSharp):
    1. void TryToReload()
    2.         {
    3.             for (int i = 0; i < ammoBox.typesOfAmmunition.Count; i++)
    4.             {
    5.                 if (ammoBox.typesOfAmmunition[i].ammoName == ammoName)
    6.                 {
    7.                     if (ammoBox.typesOfAmmunition[i].ammoCurrentCarried > 0 &&
    8.                         currentAmmo != clipSize &&
    9.                         !gunMaster.isReloading)
    10.                     {
    11.                         gunMaster.isReloading = true;
    12.                         gunMaster.isGunLoaded = false;
    13.  
    14.                         if (myAnimator != null)
    15.                         {
    16.                             myAnimator.SetTrigger("Reload");
    17.                         }
    18.                         else
    19.                         {
    20.                             StartCoroutine(ReloadWithoutAnimation());
    21.                         }
    22.                     }
    23.                     break;
    24.                 }
    25.             }
    26.         }
     
  27. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Definitely A+
    Excellent work. Everything fulfilled and good touch of humour at the end! Good idea using spheres as lamps!
     
    Saurabh-Saralaya likes this.
  28. Saurabh-Saralaya

    Saurabh-Saralaya

    Joined:
    Apr 28, 2016
    Posts:
    23
    1. Well the first problems started when the gun would neither reload nor shoot.
    (Same thing happened in the new Module above)
    2.And then came the bug where the Reload animation would play thrice for burstFireReload,
    3.or i could keep tapping 'r' and the reload animation kept on restarting.
    (This happend due to the Animator Trigger Statement which was out of if statement, and when i put it back in [1] would happen :/ )

    So i had to put those validations and the break statements, because the gun would try to reload even when there was no ammo in the ammoBox or no ammo in the clip altogether.

    In the end it resulted in a working but messy script with lots of validations.
    Well i'll redo the whole script again and see what will happen.
     
  29. NPBirader

    NPBirader

    Joined:
    Feb 23, 2015
    Posts:
    20
    I have a question
    Now I have my Player_DetectItem Script and i Changed it to a script that not detects only items. It detects things like cars, notes, and other stuff. The way i have donne it was to copy the CastRayForDetectingItem and the CheckForItemPickupAttempt function and change the variables to my new ones. For example instead of layertodetectitem i created a new one called layertodetectnotes and a noteInRange bool and a transform NoteavailableforPickup. I think its no good because im creating more sphrerecast that the performance slows down and I saw when i have an Item and a Note nearby, the text is overlaping. I tried to fix that but no sucess. Could someone help me and does someone have a better solution than creating multiplie spherecasts?

    I have seen another weird thing. Someone posted it here but its gonne. I have a gun with damage 50 and i have an Enemy with Health 100. When i shoot the enemy he dies imediatly what should not happen. When i shoot the barrels some of them are burning and some of them are exploding imediatly what should also not happening. What could be the problem?There are lags too for example when i shoot the first time since i pressed play it lags and later it gets normal.
    The same by the barrels It lags when i shoot and lazer its normal.
    Have you GTGD ore someone for all this an idea?
     
    Last edited: Jul 11, 2016
  30. andreas-lazar

    andreas-lazar

    Joined:
    Jun 22, 2016
    Posts:
    1
    Yesterday I came upon the same problem. I asked here the same, but in the new forum... my post is gone now, but in the mean time I found the problem.

    One was that I wrote gunMaster.EventShotDefault += ApplyDamage; in the OnDisable() method in Gun_ApplyDamage.cs instead of gunMaster.EventShotDefault -= ApplyDamage; Simple copy and paste error.
    The other problem I found out is in the OpenFire() method in Gun_Shoot.cs. (Copy paste can be bad...)

    I you followed the tutorial, you'll have the following code:
    Code (CSharp):
    1. if(Physics.Raycast(...))
    2. {
    3.     gunMaster.CallEventShotDefault(...);
    4.  
    5.     if(compare tag to find out if it is an enemy)
    6.     {
    7.         gunMaster.CallEventShotEnemy(...);
    8.     }
    9. }
    If you shoot an enemy, it first deducts the damage in CallEventShotDefault, then in CallEventShotEnemy which is leading to twice the damage.

    By changing it to the following, it works as expected.
    Code (CSharp):
    1. if(Physics.Raycast(...)
    2. {
    3.     if(compare tag to find out if it is an enemy)
    4.     {
    5.         gunMaster.CallEventShotEnemy(...);
    6.     }
    7.     else
    8.     {
    9.         gunMaster.CallEventShotDefault(...);
    10.     }
    11. }
    I've double checked this in the scripts in the Steam package, and there is the same. However I'm not 100% sure, if GTGD has some other mechanism to avoid this problem, which I have not found.

    I hope this helps.


    @GTGD: This is by far the best coding related tutorial I have seen in several years of trying to follow tutorials. Great work and many many thanks!


    Update: formatted code
     
    Last edited: Jul 12, 2016
  31. NPBirader

    NPBirader

    Joined:
    Feb 23, 2015
    Posts:
    20
    I have fixed it with with your solution. I was looking at the code and i was saying that it makes no sense with that.
    Now its all good. But the lags with the barrels arent gone
     
  32. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    With respect to damage doubling what andreas has written is correct and there is a bug in my script. As for a lag with barrels use the profiler to see what is causing the performance spike
     
  33. NPBirader

    NPBirader

    Joined:
    Feb 23, 2015
    Posts:
    20
    Ok i will see
    Would it be possible to make a video how the profiler works and how to detect issues.
    I have another question
    Now I have my Player_DetectItem Script and i Changed it to a script that not detects only items. It detects things like cars, notes, and other stuff. The way i have donne it was to copy the CastRayForDetectingItem and the CheckForItemPickupAttempt function and change the variables to my new ones. For example instead of layertodetectitem i created a new one called layertodetectnotes and a noteInRange bool and a transform NoteavailableforPickup. I think its no good because im creating more sphrerecast that the performance slows down and I saw when i have an Item and a Note nearby, the text is overlaping. I tried to fix that but no sucess. Could someone help me and does someone have a better solution than creating multiplie spherecasts?
     
    Last edited: Jul 16, 2016
  34. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Yeah that doesn't like a good idea to have so many spherecasts. I've had a rough idea and maybe for quest/environment interactive items you can have a script on that object instead and maybe a small OnTriggerEnter collider. So when the player is close enough to that object they can interact with it. The object checks if the player is facing it. Perhaps the text field is attached to the object and will activate and face the player when they enter the collider trigger? This way you won't need to constantly cast a sphere cast for these items. The trigger collider is set to only detect the player layer and so that will make it more efficient.

    For large objects like cars/planes/etc. I recommend having a separate script and system. Use a raycast and not a spherecast because it is a big object. Also the raycast perhaps doesn't need to fire every update because it is easier for the player to interact with bigger objects.
     
  35. NPBirader

    NPBirader

    Joined:
    Feb 23, 2015
    Posts:
    20
    I have a last question .
    I have noticed something weird with my weapons. If the weapons are at the 0 point of the scene its normal the blue red green arrows are exact in the middle but when i slide the weapon far away these arrows are changing the position so its not in the centre?
    I think its the canvasdynamiccrosshair.
    Any ideas?
     
  36. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    You probably haven't gotten to video 112 yet. You have to make a dummy camera that is permanently part of the gun and disabled and the so the canvasdynamiccrosshair will refer to that when the game isn't running. This ensures you can move the weapon about normally. When the game starts the canvasdynamiccrosshair will refer to the player's camera so that the player sees the cross hair on the screen properly
     
  37. NPBirader

    NPBirader

    Joined:
    Feb 23, 2015
    Posts:
    20
    Ok im sorry how i was able to not notice it
    Thank you. Now one very last question. The first gun works perfect. I can shoot all the ammo and if its empty it will not reload. But with the seccond gun at the end if the ammo is totaly zero. The gun plays the reload animation if i reload. And im getting a warning mesage with unreachable code.can you help Please dont hate me :(
     
  38. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Lols
    That doesn't sound right at all though. Double check that your ammo names are correct for the weapon and ammobox. Also look into what this unreachable code is, it might help you figure out what is going wrong
     
  39. NPBirader

    NPBirader

    Joined:
    Feb 23, 2015
    Posts:
    20
    Ok. Sorry that i annoyed you. I watched this warning message in the Gun_Ammo before. It was in the Trytoreload method.
    I thought a warning message would not be causing problems and
    i saw no problems now it fixed the reloading and it no longer lags when i shoot. There was simply an if statement missing with the Ammoname.
     
  40. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    No you didn't annoy, anyway all good that you found your solution. Oh here's an update on Chapter 9.

     
    eses and NPBirader like this.
  41. Deleted User

    Deleted User

    Guest

    Hey GTGD, would just like to see if this thread is still alive, I'm halfway through chapter 1 and am so grateful that this whole tutorial series exists, I must have scrolled passed your tutorials so many times on Youtube. Hopefully soon I will be able to submit my Assignment. Thanks again
     
  42. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Lols of course it's still alive, the previous post was last week. Looking forward to seeing your assignment. You'll find that the list of videos is continuing to expand on the first post, and that will continue until I've completed chapter 10.
     
  43. YED

    YED

    Joined:
    Jul 26, 2016
    Posts:
    6
    Hello, I found a bug in the "Simple Multiplayer Game". This video will describe:
     
  44. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Review your code, that is most likely where the problem is. You can refer to Unity's scripts on their learn page. You can copy them over your own and soon identify what the mistake is in your code.
     
  45. YED

    YED

    Joined:
    Jul 26, 2016
    Posts:
    6
    I bought your tutorials on Steam. I am using your scripts from your Scripts folder in GTGD S3 folder.
     
  46. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Thanks, then there is a problem, I'll have to look into it
     
  47. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Ok thanks for bringing this up, the fix is nice and simple. The syncvar is doing it's job and the health is actually being correctly being applied on the health script when a new client connects. What isn't happening is that the hook function OnChangeHealth does not get called on a new client, so the health bar isn't updated. Just call the method in Start like this and it should be fine

    Code (CSharp):
    1.         void Start()
    2.         {
    3.             if (isLocalPlayer)
    4.             {
    5.                 spawnPoints = FindObjectsOfType<NetworkStartPosition>();
    6.             }
    7.  
    8.             OnChangeHealth(currentHealth);
    9.         }
     
  48. YED

    YED

    Joined:
    Jul 26, 2016
    Posts:
    6
    Thanks so much. Will you teach how to aim with a gun and how to add headshot ability? Also can you teach me how to make a grappling hook? Because grappling hooks are the best things in games for me :)

    Edit: I mean singleplayer.
     
    Last edited: Jul 31, 2016
  49. GTGD

    GTGD

    Joined:
    Feb 7, 2012
    Posts:
    436
    Lols, nah not at this time for multiplayer sorry. I've got tons of ongoing work to do on GTGD S3, and Weekend Drive.
     
  50. YED

    YED

    Joined:
    Jul 26, 2016
    Posts:
    6
    I don't want to do that in Multiplayer :D I just want to use it on a single player game.
    But I didn't mean multiplayer :D Can you teach this on singleplayer? It is the question :p