Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Managing a point system that adds points via zombie deaths

Discussion in 'Scripting' started by CyberGNetics, Feb 11, 2021.

  1. CyberGNetics

    CyberGNetics

    Joined:
    May 10, 2020
    Posts:
    5
    Im currently building a point system that does this,

    adds 100 points to total score if green mob dies
    adds 250 points to total score if yellow mob dies
    adds 500 points to total score if red mob dies

    Im stuck right now. I was thinking of using queues to store runtime instantiated mobs in their respective own queue and check whether if this mob type dies by bullet, add points to scoresystem.

    Any suggestion will be greatly appreciated. If my method is overly complicated. Feel free to propose another way.

    TBH im looking for a way to check which mob type died by my player's bullets so that i can update the score system with the appropriate points.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,724
    You should store the score value of the mob in a script attached to the mob. Then you can use the data from that script to update your score appropriately.
     
  3. CyberGNetics

    CyberGNetics

    Joined:
    May 10, 2020
    Posts:
    5
    @PraetorBlue
    so make three new scripts to attach to each one? Ill try that. Would it still work if i created a var for each point value in their respective scripts? like make a var for green mob's value in its own mob script.
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,724
    No. One script with a damage field, and just set different damage amounts for each enemy in the inspector.
     
  5. CyberGNetics

    CyberGNetics

    Joined:
    May 10, 2020
    Posts:
    5
    Ok thanks ill try to make it work