Can't add correctly the ponts of the score

Hi to everybody. Like I wrote in the subject, I have some problem in my experimental game.
I want that when my sprite collide with enemy subtract 1 life (and that is ok, it works fine), and when collide with another object add 1 life. So I create a scene variable with “add 1” property for this second case, but when the my sprite collide with the “good one” (called medicina), on the first attempt subtract 3, on the second add 1, on the 3rd add 2 and so on…
In the screenshot put here you can’t see it, but now I also put trigger once under the collision event. Can someone help me please?

Did you put trigger once under both collision events?

Thanks for the answer. Yes I have.

Ok on the first text line try this instead…

Change text Vite ADD Variable(PuntiMed)

Hi. is not working. is not counting me at all…

Ok you could create 2 new variables.
A variable for CV and a variable for the Total Amount
So every time there’s a collision with CV - subtract 1 from the variable CV
Then you can display the Total Amount by doing Medicina variable - CV variable.
Here is an example…

Sorry my newbie questions… but what value I must give to these 2 variables?
I guess that before of what you put it goes something like:

Change the scene variable CV: set to something and the same goes for the variable Medicina… right?

Ok now I put the two new create scene variable at the beginning of the scene. CV subtract 1 and Medicina add1.
Then I put the code you indicated and wit cv subtract me 3 point now, and with Medicina,also if I changed the operator from - to +, instead to increase me the points, it goes to 0. Thanks again for your precious help.

The scene starts with all variables set to 0. But I think I’m over-complicating things. Sorry about that. In your graphic above, at the moment you have…

Change the text Vite subtract “1”

just try to change this to

Change text Vite SET TO Variable(PuntiMed) - 1

Does that work?

Nope, I get this:

Anycase is the part with medicina that is not increasing the lives. What I had with cv was working with Change the text Vite subtract “1”, the proble is that if I use the sam on Medicine changig from subtract to add, it will add me 1 on the end of the number. for example 4+1 is 41 instead of 5…

Ok put everything back to how you had before (forget about those new medicina and cv variables that I mentioned for now)
put everything back to this

but not this line

use this one instead

Not sure if that will work… Do you need to save your PuntiMed variable for something later?

If you don’t need to save it you could just reverse what you did in the medicina collision action , do that in the cv collision action like this >


Ok the previous one did not work. I will try this. :+1:

Maybe I found a way… the one you suggest me I used also for medicine, adding instead of subtracting. It works, only that instead to increase from the actual number of lives it starts from 1, so I created an object variable,( but I guess can try also with scene variable ) with value 5 and adding that to ToString(Variable(PuntiMed)) in this way:
ToString(Variable(PuntiMed)+Vite.Variable(Lives)). The same I will try with cv. But now I am on the job. I will let you know during my pause if is working.

Ok, but if you just want the Vite text to add 1 or minus 1 depending on one of the collisions - if it collides with medicina add 1, if it collides with cv -1, the easiest way is this I think. It should just add or minus 1 depending on which one it is colliding with.
The first 2 actions are connected to your first condition which is the Medicina collision
The second 2 actions are connected to your second condition which is the CV collision

Thanks! Your last suggestion works. Everything is Working good now. Thank so much for your help and especially for your time.

1 Like