Download

Increment a counter?

Hi all,
Im new to UE4 and C++ and I cant for the life of me figure out how to increment a basic counter…just say if you walk into a volume and each time you do, you lose 1 point of health or something.
Ive done this in C# with Unity but like I said, i cant figure out how to do it in C++.

I know its a pretty basic thing but if anyone could help id really appreciate it xD

In the header file of the class where you detect the collision you can declare a variable, lets say “Counter”



int Counter;


Then in the constructor of the class you assign a value to your variable, e.g. 0:



Counter=0;


And whenever you detect a collision you can simply do:



//...]
Counter++;
//or
Counter=Counter+1;
//or 
Counter+=1;
//...]


Hope that helps.
Taces