# How to add up the total of three different scores in the BGE? [duplicate]

I have 3 properties from three different "throws" in a game in which I want to add up the 3 scores and produce a total.

I have 3 properties holding each score and those work fine. I have a 4th property as a total which I then use "assign" "THROW 1+THROW 2+THROW 3" but the total always comes to -1.

I have everything typed correctly but not sure how to solve this. Using python is not an option with my limited programming skills.

Using logic bricks you assign the calculated result to the final score property. The value field for the assign is a python string that can use the property names directly. The thing to check would be that the type of each property can hold a numeric value.

Another way to do it would be to add to both scores at the same time, by connecting two property actuators to the same controller. But that would depend on whether you had both scores displayed at the same time.

You only need limited programming skills to use python for this example, the script to do it is only a few lines and is easy to understand.

import bge

cont = bge.logic.getCurrentController()
player = cont.owner

player['final'] = player['score1'] + player['score2'] + player['score3']


The getCurrentController gets the python controller that is running the script, the owner of that is the object with the game properties. You put the property name inside square brackets ['score1'] to use the value in the script.