PLAY THE GAME USING THE SHAREMYGAME LINK

Inspiration

This game was partially inspired by the simplicity of arcade FPS games as well as games like COD zombies and other PvE based games

Aim

The aim was to design a simple yet engaging timewaster which would hold both the desired “YEE HAW” appeal, alongside the core aims of a first-person shooter.

What it is

A single person first person shooting game, where the objective is simple, kill all the zombies. The game is built as a bit of mindless fun and stress relief.

How I built it

It utilises C# on the Unity game engine. The code mainly works to conduct the interactions between the different game objects,

Challenges I ran into

Programming the bullet interaction and designing the muzzle flashes and particle effects were quite difficult, the code was not as complex as other projects ive worked on, but the extent to which I had to delve into the UnityEngine.UI library was somewhat unprecedented given the task it was used for (creating a healthbar). The version of Unity I am currently using seems to have a bug which messes up what happens when you switch to an all UI scene.

Accomplishments that I'm proud of

The healthbar easily took a while, and even though it isn't the most polished due to time restrictions, the simplicity of it as well as well as the fact that it works to an extent is something I am proud of.

void Start()
    {
        image = imgObj.GetComponent<RectTransform>();
    }
    // Start is called before the first frame update
    private void OnCollisionEnter(Collision collision)
    {
        print(1);
        if(collision.gameObject.tag == "Enemy")
        {
            health -= 1;
            image.offsetMax = new Vector2(image.offsetMax.x - 300f / health, image.offsetMax.y);
        }
    }

Though it is a single line of code, it was hard to find resources based on modifying a rectangle in such a manner, other accomplishments also include the firing and the muzzle flashes.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Utility;

public class guns : MonoBehaviour
{
    public float damageAmount = 5f;
    public float range = 100f;
    public ParticleSystem muzzleFlash;
    public GameObject impactEffect;
    public Camera camera;
    private void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            muzzleFlash.Play();
            Shoot();
        }
        else
        {
            muzzleFlash.Stop();
        }
    }
    void Shoot()
    {
        RaycastHit hit;

       if(Physics.Raycast(camera.transform.position, camera.transform.forward, out hit, range))
        {
            target target = hit.transform.GetComponent<target>();
            if (target != null)
            {
                target.takeDamage(10);
            }
        }
        GameObject Impact = Instantiate(impactEffect,hit.point,Quaternion.LookRotation(hit.normal));
        Destroy(Impact, .5f);

    }
}

What I learned

UnityEngine.UI's capabilities, simple navmesh techniques, and a plethora of intriguing titbits regarding the Unity Game engine.

What's next for Cowboys vs Zombies

Most likely, I plan on adding a story of some sort to make the game seem much more functional and improve the map and the spawning of enemies.

extra info

The game has been exported to WebGL and thus can be put onto hosts like sharemygame.com. I can later put these games on a website in order to create a freegames site. all code is visible on github

Built With

Share this project:

Updates