top of page
Search

2D Game Update

  • Writer: Keshav Batra
    Keshav Batra
  • Feb 18, 2022
  • 1 min read

Now that I'm finally done with the game jam, I've decided to return to my 2D game and optimize it. The new things that I've added are a saw and a health function. Whenever I get hit I will lose health. I even added an invincibility function so that if I get hit again, I wont get killed right away. There were initially bugs where I was still able to pickup the health despite it being full, but I was able to fix it with this code below:



private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player") //this is checking to see if the object has the tag "Player"
        {
            if (collision.GetComponent<Health>().currentHealth < collision.GetComponent<Health>().startingHealth) 
            {
                collision.GetComponent<Health>().AddHealth(HealthValue);
                //Destroy(Health);
                gameObject.SetActive(false);
            }
        }
    }




 
 
 

Comments


bottom of page