Monday, November 15, 2021

Week 9( discord Session)

 

To do list

 

1.Environment

Arena

Towers

 

2.Player Units (3D Models,)

Tank

Soldier

Archer

Air

 

3.Enemy Units

Tesla Towers

Inferno Tower

Bomb Tower

Mother ships/ Fat jets

 

4. Player’s Spell

Freeze

Damage

 

5. 2D artwork (For Every unit)





Due to Lock down I wasn't able to use Maya and Unity software at home as my laptop didn't support them , I assume it's because of computer virus, as I use lots of pre cracked software. so I have to re Install windows and start it all again clean. 


while opening Maya/ unity, this happens.








Sunday, October 31, 2021

Week 17

 

30th/ fixing bugs

I did manage to correct most of the bugs from last session. I added the audio, that would constantly play the  game and change in different scene. next I was preparing for audio on/ off button. But for some reason I ended up having bug in my game. 




Fixing Errors and bugs

As I was trying to balance cards on Unity I did some changes that disconnected all my work mechanics in Unity. The min reason was the script being misplaced. Also while adding the sound on different scene for game play, I encountered conflicts within scripts and all my particle effects were acting weird and were not in one place. I assume that's what happens when script errors occurs. 

I have been contently in touch with the Tutor Joe for further help. and I was finally able to zip my files and send it to him. I also had many conversation on discord where I shared all the images/screen shots on problems regarding game. 

I was also saving my work while I was working, is a good practice. However increment and saving would save me from having this issue. For me as a Intermediate game student. It's hard to get stuff right. I am very grateful to have Joe as a Unity Tutor who's a beast at coding and game making. I wish I could code like him one day. :)  


It is easier to be discouraged when things goes wrong. Figuring out the issue, consulting with seniors would eventually fix the thing. Also Thanks to Tutor Chris for extending due date for assignment submission, where I could polish my game nicely. 


Creating animation keyframes inside Unity. 


Instruction Section:


It is a new experience for me to do key frame animation inside unity which is more similar to after Effects and other software. I did manage to give some basic instruction on how to play game as its a part of assignment. Hence, I created a new scene called 'Instruction 'and created some text for each text and animate them, I mainly tweaked some position, scale and rotation values for its dynamic result. One thing to keep in mind is that when we press record button, the key frames are automatically put on the first frame of any animated source. This took me some time to figure out as it was not functionally well.,


Base Layer in Animator panel. right click and make selection to hover over different functions/tab, eg: hello, exit as shown in the picture. 

Also different function have their own properties bar. where we can adjust its overall speed, offset values.

As my key frames were very fast, I did manage to change its speed by 0.3 times. and It appeared fine. 


Tuesday, October 26, 2021

Week 16

 Coding:

One of the best part of gaming making is coding, with which results are easy to achieve, for me the basics on coding got quite interesting as I carry to revise them thoroughly. 

Some of the basics code that I felt easy were, buttons for scene management, providing  options for character like health, attack, destroy, time frame etc. But Some were quite challenging for me to set up by myself which were written by game tutor, Joe.


Here are some of the sample of coding that we did which can be handy for future use and learning.


*Scene management

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.SceneManagement;


public class MainmenuScriptExit : MonoBehaviour

{

        public void MainMenuBtn ()

        {

            SceneManager.LoadScene(0);

        }


    }


*Destroy 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class Destroy : MonoBehaviour

{

    public void DestroyObject()

    {

        gameObject.transform.position = new Vector3(0, 0, 1000);

        if(gameObject.name == "cpuKT")

        {

            GameObject.Find("GameController").GetComponent<GameController>().gameWin = true;

        }

        //Destroy(gameObject);

    }

}



*Enemy
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class enemy : MonoBehaviour
{
    [SerializeField] public int health;

    private void Update()
    {
        if(health <= 0)
        {
            gameObject.transform.parent.GetComponent<Destroy>().DestroyObject();
        }
    }
}


*Enemy Controller

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyController : MonoBehaviour
{
    [SerializeField] private GameObject towerPlaceholder1;

    [SerializeField] private GameObject[] EnemyTowers;

    private bool tower1empty = true;

    public float shootWaitTime1 = 1.5f;
    public float shootTimer1;

    public float shootWaitTime2 = 1.5f;
    public float shootTimer2;


    private void Start()
    {
        shootWaitTime1 = Random.Range(5, 15);
    }
    private void Update()
    {
        if(Time.time > shootWaitTime1)
        {
            int ran = Random.Range(5, 15);
            shootWaitTime1 = Time.time + ran;
            int ran2 = Random.Range(0, EnemyTowers.Length);
            if (tower1empty)
            {
                tower1empty = false;
                GameObject go = Instantiate(EnemyTowers[ran2], towerPlaceholder1.transform.position, Quaternion.identity);
                go.transform.SetParent(towerPlaceholder1.transform);
            }
        }
    }
}


*Creating Minions( they are the attacking units with different properties like health, speed, attack, range etc.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class CreateMinion : MonoBehaviour
{
    private GameController GC;
    public Minion minion;

    private Transform goal;
    private NavMeshAgent agent;

    void Start()
    {
        GC = GameObject.Find("GameController").GetComponent<GameController>();
        minion = GC.activeMinion;

        //goal = GameObject.Find("cpuT").transform;
        agent = GetComponent<NavMeshAgent>();

        agent.speed = minion.speed;

        GameObject GO = Instantiate(minion.prefab, gameObject.transform.position, Quaternion.identity);
        GO.transform.parent = gameObject.transform;
    }

    private void Update()
    {
/*        if (agent.isOnNavMesh == true)
        {
            agent.destination = goal.position;
        }*/
    }
}

*Fire Tower Script
a fire tower shoots enemy that are projected by player, it does track and shoot ememies very well. this includes particle effects that follow enemy and reduces its health. 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FireTower : MonoBehaviour
{
    public List<Transform> unitsInRange = new List<Transform>();
    public float distanceTo = 99999;
    public float damage;

    [SerializeField] public Transform target;
    private float turnSpeed = 1;

    [SerializeField] public ParticleSystem fire;

    private void Start()
    {
        fire.Stop();

    }

    private void Update()
    {
        if (target == null)
        {
            fire.Stop();
            FindTarget();

        }else if (target != null)
        {
            fire.Play();
            Vector3 targetDir = target.position - transform.position;
            float step = turnSpeed * Time.deltaTime;
            Vector3 newDir = Vector3.RotateTowards(transform.forward, targetDir, step, 0.0f);
            //Debug.DrawRay(transform.position, newDir, Color.green);
            transform.rotation = Quaternion.LookRotation(newDir);
            target.GetComponent<MinionController>().curHealth -= damage * Time.deltaTime;
        }
    }

    void UpdateUnits()
    {
        foreach (Transform t in unitsInRange)
        {
            t.GetComponent<MinionController>().FindGoal();
        }
    }
    public void FindTarget()
    {
        foreach (Transform t in unitsInRange)
        {
            float distance = Vector3.Distance(gameObject.transform.position, t.transform.position);
            if (distance < distanceTo)
            {
                target = t.transform;
            }
        }
    }
}

* Canon shoot( I use this to shoot users units,

using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class cannon : MonoBehaviour

{

    public  List<Transform> unitsInRange = new List<Transform>();

    public float distanceTo = 99999;

    [SerializeField] public Transform target;

    private float turnSpeed = 1;


    //Shooting variables

    public float shootWaitTime = 1.5f;

    public float shootTimer;

    [SerializeField] private GameObject cannonBall;

    [SerializeField] private Transform spawnPoint;



    private void Update()

    {

        if(target == null)

        {

            FindTarget();

        }

        if (target != null)

        {

            Vector3 targetDir = target.position - transform.position;

            float step = turnSpeed * Time.deltaTime;

            Vector3 newDir = Vector3.RotateTowards(transform.forward, targetDir, step, 0.0f);

            Debug.DrawRay(transform.position, newDir, Color.green);

            transform.rotation = Quaternion.LookRotation(newDir);


            if(Time.time > shootTimer)

            {

                shootTimer = Time.time + shootWaitTime;

                Shoot();

            }

        }

    }


    public void FindTarget()

    {

        foreach (Transform t in unitsInRange)

        {

            float distance = Vector3.Distance(gameObject.transform.position, t.transform.position);

            if (distance < distanceTo)

            {

                target = t.transform;

            }

        }

    }

    void Shoot()

    {

        GameObject go = Instantiate(cannonBall, spawnPoint.position, Quaternion.identity);

        go.GetComponent<cannonBall>().target = target;

    }


/*    private void OnTriggerEnter(Collider other)

    {

        if(other.tag == "unit")

        {

            unitsInRange.Add(other.transform);

        }

    }


    private void OnTriggerExit(Collider other)

    {

        if (other.tag == "unit")

        {

            unitsInRange.Remove(other.transform);

        }

    }*/

}

*Cannon Ball
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class cannonBall : MonoBehaviour
{
    float t;
    public Transform target;
    float speed = 150f;
    private Transform startPos;

    private void Start()
    {
        startPos = gameObject.transform;
            ;
    }
    void Update()
    {
        if (target != null)
        {
            //t += Time.deltaTime / speed;
            //transform.position = Vector3.Lerp(startPos.position, target.position, t);

            transform.position = Vector3.MoveTowards(startPos.position, target.position, speed * Time.deltaTime);
        }
    }
}
these elisted scripts are working scripts that have been corrected overtime. Me recording Joe's class activities did help a lot to correct at the end. 

My next goal is to learn to code these by myself which would be a good skill to have. 
I am very much satisfied with the results. so far. and it works perfectly with the game. 

This image was taken after the all the enemies got killed by the AI's defense tower making them unable to rich Crown towers. This was because I changed some destroy value for for Ai defenses mainly, Inferno tower and Transformer. Both of them are functioning well. 







Tuesday, October 19, 2021

Week 15 (coding, audio check)

Joe recently game me a sample of a game that I was after. It worked perfectly. 




This is a sample made my Joe, while working with Joe at class. I got to know that while its a good thing to create a sample in the beginning with placeable units defined. This way, While assigning cards to the units it will follow the given path.


Special thanks cover for thanking my tutors for providing us with tremendous ideas, concept on 3D gaming.




A back button that I created for the game.

Unity comes with different version as it allows files to downgrade and use it in safe mode. I had some issue on graphics while getting files from Joe. It must be due to unsupported current graphic user interface that are not unto date on campus PC. Also, Its always good to archive successfully completed games, just to backup incase the current version goes wrong. 



Unity Hub Main folder locating to import game file. 


file Executing options.


Audio, for Audio, I decided to use only one background music as I need more time on learning and fixing codes that are not working like cannon is not shooting as it should be. Game making is all about building concepts, brain storming and implementing them on software/ coding. 


This is my audio file that I got for free on web. It sounds very old which matches my game theme. 

Percy_Wenrich_-_02_-_The_Smiler_1907_Zonophone_Concert_Band

Assigning audio is easy unity, just need to add component/audio source and assigning audio file to the source. 

For this, I watched lots of tutorials on YouTube which helped me for some extent. 






 

Tuesday, October 12, 2021

Week 14

 Animating In Maya, rig, bone, deformers

When Modeling giant, Golem, Barbs for my game. I realized that how complex these round shaped character are to model.

My first rig looks like this,

A walking scene with some boxing movemnet.





Tuesday, October 5, 2021