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

Side Tracked - 3D Zombie FPS

Discussion in 'Made With Unity' started by Samuel411, Jan 22, 2014.

  1. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    Hello, I created a 3D zombie fps game. The game is a zombie first person shooter (FPS). The object of the game is to get to the highest round you can. The rounds are unlimited, after every round the zombies get harder to defeat. They increase quickly in health, damage, and numbers. You need to keep up with them with upgrades that can be purchased in the shop. In the shop you could buy health, adrenaline (faster movement), more grenades, a damage boost for the knife, ammo, a machine gun, a shotgun, and a sniper rifle.

    You are trying to finish an essay but get side tracked and start playing a zombie fps.

    There are leaderboards for the game avalible Here.

    Play the game by clicking Here.




    Some models are not mine and can be found online!

    You can contact me by email, lementgames@yahoo.com.
    Please leave feedback!
     
    Last edited: Oct 11, 2015
    Kos-Dvornik likes this.
  2. joni-giuro

    joni-giuro

    Joined:
    Nov 21, 2013
    Posts:
    435
  3. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    I use a raycast so the issue it the colliders on the zombies. I am going to fix the colliders so there isnt any room between the joints. Also this would be caused if you were not aiming because bullets do in random directions unless aiming.
     
  4. joni-giuro

    joni-giuro

    Joined:
    Nov 21, 2013
    Posts:
    435
    I was aiming because I could see the bullets hitting the wall right behind the zombie. I'll give it a try again when you fixed it :)
     
  5. smirlianos

    smirlianos

    Joined:
    Aug 2, 2012
    Posts:
    177
    I guess yo cast the ray from the gun?

    Cast it from the main Camera, so it hits where the point is :)
     
  6. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    The colliders is fixed, the neck was missing the collider. Also if I put the ray to cast from the camera then it would hit the point even at a close distance, even though the gun is not there.
     
  7. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    The leaderboards work now!
     
  8. Destran

    Destran

    Joined:
    Feb 14, 2014
    Posts:
    7
    Played the game for like half an hour and had a good time, nice job on the animations especially. Just one critique/question, like 5 minutes in I was out of ammo and spent the next 25 minutes just knifing like crazy. Is there a way to switch guns/get more ammo that I just missed? If not, it would be nice to be able to get more ammo every once in awhile. Besides that, good job :D

    Edit: I also noticed that when I hit restart it just started me off in round 1 with full ammo/health but kept the score I'd had from my last game. But I couldn't shoot or knife. Maybe that's a problem on my end though.

    Edit #2: Reread your post and saw that there is in fact a way to buy guns/ammo in the shop. My bad, but where is the shop? :D
     
    Last edited: Mar 11, 2014
  9. DanRigg11

    DanRigg11

    Joined:
    Aug 26, 2015
    Posts:
    2
    Hi Samuel if also made a survival shooter but my rounds only increase the number of enemies not the enemy health or speed what is needed.

    using UnityEngine;
    using UnityEngine.UI;
    using System.Collections;

    public class SpawnManagerNew : MonoBehaviour {
    public int round = 1;
    int monstersInRound = 10;
    public static int monstersLeftInRound = 10;
    int monstersSpawnedInRound = 0;
    float monsterSpawnTimer = 0;
    public Transform[] monsterSpawnPoints;
    public GameObject monsterEnemy;

    public GUISkin mySkin;

    float countdown= 0;

    // use this for initialization
    void Awake () {

    }

    // Update is called once per frame
    void Update () {
    if (monstersSpawnedInRound < monstersInRound && countdown == 0)
    {
    if (monsterSpawnTimer > 3)
    {
    SpawnMonster ();
    monsterSpawnTimer = 0;
    }
    else
    {
    monsterSpawnTimer += Time.deltaTime;
    }
    }
    else if (monstersLeftInRound == 0)
    {
    StartNextRound ();
    }

    if (countdown > 0)
    countdown -= Time.deltaTime;
    else
    countdown = 0;
    }

    void SpawnMonster()
    {
    Vector3 randomSpawnPoint = monsterSpawnPoints [Random.Range (0,monsterSpawnPoints.Length)].position;
    Instantiate(monsterEnemy,randomSpawnPoint,Quaternion.identity);
    monstersSpawnedInRound ++;
    }

    void StartNextRound()
    {
    monstersInRound = monstersLeftInRound = round * 10;
    monstersSpawnedInRound = 0;
    countdown = 15;
    round++;
    RoundManager.round += 1;
    }

    void OnGUI()
    {
    GUI.skin = mySkin;
    GUIStyle style1 = mySkin.customStyles [0];

    if(countdown !=0)
    {
    GUI.Label(new Rect(Screen.width/2 - 50, Screen.height/2 - 83, 230, 80), "Next Round :");
    GUI.Label(new Rect(Screen.width/2 + 220, Screen.height/2 - 80, 160, 60), "" + Mathf.RoundToInt(countdown), style1);
    }

    }
    }
     
  10. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    Get the health and attack components when instantiating the zombies then modify those based on the current wave.
     
  11. Rin-Dev

    Rin-Dev

    Joined:
    Jun 24, 2014
    Posts:
    575
    On your zombies health script, have the variable equal itself times the number wave. You would have to reference the wave script as well to keep track of rounds.

    an example would be like

    public float Health;
    [HideInInspector]
    public float Health2;

    public void Start(){
    Health2=Health;
    Health=Health2 * GameObject.Find("NAMEOFGAMEOBJECTCONTAININGSPAWNMANAGER").GetComponent<SpawnManagerNew>().round;
    }

    While of course this would increase really quickly , it's a starting point
     
    Samuel411 likes this.
  12. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    This code would work but is pretty un-optimized, you'd be calling GameObject.Find on every zombie that spawns, you'll get lag spikes after each wave. The explanation I posed is what I still believe would be the best implementation, editing the health when you spawn the zombie.
     
  13. Rin-Dev

    Rin-Dev

    Joined:
    Jun 24, 2014
    Posts:
    575
    This would be a start function on each zombies script, unless all your zombies have one single health script, I don't see why it wouldn't work well. It edits their health once at the start of every wave just the same.
     
  14. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    Exactly my point, if you have a lot of zombies and each zombie runs 'GameObject.Find' it'll result in a huge lag spike when a new wave starts. Think of it like this,

    zombiePrefab has health script
    wave 8 starts -> 8 zombiePrefab objects instantiated -> all 8 zombies run their start method (GameObject.Find)
    vs
    wave 8 starts -> 8 zombiePrefab object instantiated and after instantiating, do (ZombieObject.GetComponent) for each one

    The (GameObject.Find) method will be completely unusable in scenes with hundreds and thousands of objects and during waves that get into the dozens.
     
  15. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    This project is soo old lol I made it while learning some the basics of unity and looking at this code is making me cry...
     
  16. Rin-Dev

    Rin-Dev

    Joined:
    Jun 24, 2014
    Posts:
    575
    How do you reference your rounds then ?
     
  17. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    I spawn my zombies from my ZombieSpawning script then that script keeps a reference of the WaveManager script.
     
  18. Rin-Dev

    Rin-Dev

    Joined:
    Jun 24, 2014
    Posts:
    575
    I mean for your individual zombies, how do you keep their health scripts to reference what round you are on ?
     
  19. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    I don't have to keep a reference to them since their health changes when they are spawned.
     
  20. nxtboyIII

    nxtboyIII

    Joined:
    Jun 4, 2015
    Posts:
    280