Search Unity

calculating shooting accuracy

Discussion in 'General Discussion' started by NinjaRubberBand, May 9, 2016.

  1. NinjaRubberBand

    NinjaRubberBand

    Joined:
    Feb 22, 2013
    Posts:
    243
    I understand math, but im having trouble figuring out how to achieve this.
    The game is a beer pong game, and i want to show the accuracy of the shootings.
    For example if you hit all the 6 cups in 6 shots, the accuracy is 100%
    If u hit the 6 cups in 12 shots, the accuracy is 50%.
    What math formula can i write to make this?
    So i know what my accuracy is, if i hit the 6 cups in 56 shots. Thank u!
     
  2. HemiMG

    HemiMG

    Joined:
    Jan 17, 2014
    Posts:
    911
    If I understand the question right, the you would divide 6 by 56 and then multiply by 100. It would be a little over 10% accurate. For example 6 divided by 12 is 0.5, multiply that by 100 and you get 50%, 6 divided by 6 is 1, times 100 is 100%. Don't multiply by 100 if you need the accuracy for other calculations rather than for user display.
     
    McMayhem and theANMATOR2b like this.
  3. NinjaRubberBand

    NinjaRubberBand

    Joined:
    Feb 22, 2013
    Posts:
    243
    Thank you! Just what i needed.
     
  4. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    you understand math, but not basic percentage calculation?
     
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,570
    Percentage = Shots_Hit * 100 / Shots_fired.

    Or...

    Percentage = Quantity * 100 / Capacity.
     
    unity_LwuXLuYNxIPMaQ likes this.