Int Problem need help fast.

So i have a click event game you click the object flying towards you and it adds up how many you have with the hud. But for some reason it will not add for me. It goes from 0 to 1 then it just stays at 1. How can i get it to keep going past 1. In the level blueprint i have it set so i posess a camera when the game starts. so i’m not using the “MyCharacter” because you do no need to move. And i have all of setup inside the blueprint of the static mesh that you click. Here is my blueprint. Can anyone help me fix .

Add Score:

Score Hud:

i did that and now it jumps from 0 to 2 then does not go higher than 2.

It should be fixed. But it just shows where i moved the pin. But that way does not work either. I goes from 0 straight to 2 and does not go any further.

Ok i just hooked up a Event tick to the blueprint i posted above and it works fine with the event tick. But i dont want it to count up with the event tick. I want it to count up every time i finish the process i have before it. Does anyone know why it would work with the event tick and not with anything else.?

I still cannot get to work does anyone know what the problem is.?

If you still have hooked up the same as in your first post, you will need to connect it like , otherwise it will never update the score in your HUD:

I tried that but its still not working. Ill post my full Bp and see if that helps.

Hi, after setting Score0 to (Score0 + 1) you’re actually passing (Score0 + 1) to the Score function instead the current value Score0. To fix that, link Score0 to the Score function, not Score0 + 1.

Clarification: Pure functions (those without incoming execution pin) are actually executed every time they are needed, thats why the add happens twice.

Ok That fixed that part but it still does not go any higher than 1. I starts at 0 then goes to 1 then never goes any higher. Do you know what could be causing that?

Hello,
I wonder if the actor destroyed is the same or a new one. Because if is a new one, then is a new score which is 0. In case of is the trouble, you’ll have to set score in level and use an evnt dispatcher to set score.

Ive never used “Game Instances” so i’m not sure how to use them. Can you explain what they do.?

Also i tried a event dispatcher and it did not work.

All i’m trying to do is take the Int (which starts at 0) and add + everytime the actor i click get destroyed. Then print that on the screen. I never thought would take as long as it has.

I think i get it : Set your variable score in your hud and in your event do get player controller / get hud / get score / set score = score +1 / draw text, would work fine without more needd.

Yeah Fen’s way should work for you, but the reason for all the hassle is you are setting the value within one of the present’s blueprint (I’m assuming that’s what it is), since there are multiple blueprints all adding 1 to their initial score of 0, all of them return 1.

You need to set the score globally instead of inside the object. :slight_smile:

i’m not sure what you mean by “and in your event do get player controller / get hud / get score / set score = score +1 / draw text” What event do you mean.? The score function in the blueprint interface?

I’m still pretty new to blueprint. I did it that way because i wanted it to add after the object was destroyed. How else can i tell it to add when its destroyed if its not in that blueprint.?

I did it quickly :
4e00b2db5c0c7c11c6dc7ad3ae20644b2427bd0e.jpeg
Personaly, i would do the draw and then only destroy component / actor. File updated !

Thank you! I understand what you ment now. i never thought about casting to a Custom event but now i know. I guess i still have alot to learn.

Welcome in the perpetual learners team :smiley:

Edit : I just gave a try : no need to do the draw after the update score. It will update by itself. I 've uploaded a new pic with correct setting in case of someone needs it later.

Edit 2 : Keep time to check game instance infos from the britain : It is really usefull stuff.

@anonymous_user_9c39f750 Britain : a tutorial set in community section would be really appreciated by all of us :wink:

Ok now i have a similar problem. i recreated the thing you posted but now i want it to subtract at a certain point. but there is only 1 text pin so how can i have to subtract when it needs to but also add. They way i have it setup it works fine the first time. Then the second time it starts multipling. How can i fix .

I also have a video because i’m bad at explaining. Watch the counter on the top right.I have the cap set to 20 with a clamp. But after i destroy the 1st present it starts increasing the number in the counter by 2’s. I have the subtraction working but its causing the numbers to increase alot. Thats what i cannot figure out how to fix.(Ignore the bad lighting i forgot to rebuild :p)

To fix that, you need to remove one of the pins from the “Add Float” node, right now you are adding (score + score + 1) so you need it to be only Score + 1, should fix it: :slight_smile:
math.PNG

EDIT: Is that a unicorn in the background of your pic Fen?? so random :wink: