Example one – we could really put this in any Blueprint that gets called into the level. We’ll put it in the ThirdPersonCharacter blueprint. Notice I also made a key pressed event to trigger this. I just right clicked in the event graph and typed ‘p’.
Example Two – now we can use this logic in a more real way to add up how many times the player runs into a token that’s placed in the level. This is in our own Actor Blueprint we created in the content browser, named it “token”and placed a mesh into it in the viewport. Once we add all the logic below we can see it work by dragging the “token” actor blueprint into the level.
Here we’re also doing something new called “casting.” That’s when you go into another blueprint that is part of your game and get and set variables. Here we’re casting into the player character blueprint and adding up the score variable. 
In addition to casting and the key pressed event we’re learning two of our first variables here:
- Integer – (dark green color) which is just a number with no decimal point (examples: 4, 566455, 2, 0, -39392, -3, etc)
- Boolean – (dark red color) which can only be true or false (0 or 1) We check the boolean with a “branch” node.
- Here is a little more about variables.
Challenge – how can we make a level where a player has to collect ten tokens to advance to the next level?
Here is a small version of that:
A little more explanation as to why we are doing casting – if we just put all the variables in the Coin_BP each coin actor would only add up their overlap so you would get 1 printed to the screen every time you find a coin. Casting to another BP such as the player character allows us to have a place to store this information. There are a lot of other ways to do this but for now this is the simplest.
Also – at the end of the video I’m duplicating the coin BP by holding down alt when I move it.
