Search Unity

Add all the ints from a list and give me score.

Discussion in 'Scripting' started by stringHakunaMatata, Mar 14, 2021.

  1. stringHakunaMatata

    stringHakunaMatata

    Joined:
    Mar 7, 2021
    Posts:
    3
    In very simple words what I want to do is, add all the ints which are in a list and give me a total of that as score.
    Note : I am an artist just trying to code my game so, whatever you tell me be sure to explain it.
    debug.log = "Thanks"
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,727
    Here are some steps you need to do:

    - create a total variable and set it to zero

    - iterate the collection (list? array?) and sum each value into the total variable

    That should give you enough to google on.