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

Scripting Boss in 2D Game?

Discussion in 'Scripting' started by JonathanGentile1, Sep 19, 2018.

Thread Status:
Not open for further replies.
  1. JonathanGentile1

    JonathanGentile1

    Joined:
    May 2, 2018
    Posts:
    7
    Hello,

    I'm scripting a boss for my game. Right now my task is to be able to have the boss be damageable and to die. I have a bit of pseudo-code, I'm just not sure how I would execute this task. My idea is to have two fireballs that the player has to "kill." If the player kills both fireballs, the boss only has to be hit once to die. But if the player didn't kill any fireballs, the boss has to be hit 50 times to die. This is the code I have so far:

    var JumpsToKill = 50

    IF "player" collides2D with boss
    decrement JumpsToKill

    IF JumpsToKill = 0
    kill boss

    IF Fireball1 = dead
    AND IF Fireball 2 = dead
    JumpsToKill = 1
     
  2. shawnrevels

    shawnrevels

    Joined:
    Aug 13, 2014
    Posts:
    86
    That's not a script at all...
     
  3. shawnrevels

    shawnrevels

    Joined:
    Aug 13, 2014
    Posts:
    86
    Best bet would be to state an int.

    Code (CSharp):
    1. public int bossHealth = 100;
    Then oncollideenter2d you want to minus what ever amount you want.

    Then if bosshealth = 0 then he dies..
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    shawnrevels and Joe-Censored like this.
Thread Status:
Not open for further replies.