2/7


HAR-CORE PARKOUR

Start your day with a warm-up


Test each other's parkour game



What are you learning?

Power-Ups & coins: Working with Public Variables

Why is it important?

You will want to add different values to items in your game

How do you show that you understand? What is the assignment?

Follow along



Add a checkpoint

Let's place a camera spot so we can quickly get back to a specific spot

Hold CTRL + a number to bookmark/save that spot

So if I hit CTRL + 7, I can move around and whenever I press the 7 key, I will go back to that spot.

We want to add a power up to help the character make a bigger jump

Go to your blueprints in the content drawer and find BP_JumpBoost

Right Click and select play from here

Walk over the checkpoint and make sure it turns blue then walk off the edge to see the checkpoint functioning correctly

Walk in the entract and take the moving platform to the other side

Drag the boost into your game

Test your game

Hit the checkpoint

Hit the boost

Make the jump

Double click on the boost to open the blueprint

At the start of the blueprint we have On Component Begin Overlap (Sphere_coll) Short for Sphere Collision (I called it a coil in the last video)

This is the same as we had for the checkpoints

When an object overlaps (touches) the collision, it activates the blueprint and moves on 

Next step is casting/sending the info to the character from the blueprint.

The goal is to have the movement change when we overlap the collision on the powerup.

We are going to change the movement with a variable

*** The variable in this case is just a number that is changeable***

Dock the blueprint and go back to the game

When you select the jump boost, you can see the variable in the details panel along with the cool down time

So these are the variables that will change the players ability as soon as you overlap/collide/touch the boost

The 1500 is how much "power" the character has (the regular jump velocity is 600)

The cool down time is how long the jump boost lasts for 

These variables are called floats which is just a cool way of saying a number with a decimal

Our goal is to get to the Activity 3 destination

As is, it is not possible

Explore the cool down time and test to see if you can make it to this point after getting the power up

If not, try adding to the jump velocity to find the sweet spot between making it to the destination while still making it hard enough to be a challenge

The variables you can modify are called public variables

These variables can be modified for each individual instance of the object

Add another boost to the game and change the jump velocity

Notice when you switch from the two, the jump velocity is not the same

***If you are going to add boosts of different jump velocities, consider changing the size of the one with the higher velocity so the player can differentiate between them.

Go back to the jumpBoost Blueprint

Next open the game folder in your blueprints file and double click the character to open the character blueprint

What we are going to be focusing on right now is the Character Movement

Select Character Movement from the left side

Find Jump Velocity in the details

Go back to the jumpboost blueprint

When you look at My Blueprint on the bottom left under variables you will see Jump

To the right of Jump Velocity is an eye

This eye means that it is a public variable and can be modified inside the game (not just in the blueprint)

Select the Jump Velocity variable

The number on the right is the variable that you are changing inside the blueprint

They are all the same thing

Toggle Visibility is making the power up invisible once the character touches the object and starts the blueprint

Set Collision Enabled

Stops the collision so it disappears and you aren't continually colliding with it

We did this with GDevelop

Delay

The cool down time is just the name of the variable that causes the delay

 Delay is complete, the power up is toggled and the powerup is visible again

After the visibility is back, the collision is reset so the player can get the powerup again

? Is Valid is checking to see if the player is still alive

This changes the variable back to the original velocity

Go back to your game

In the command prompt

Type

Show Collision 

Exactly like is is 

Play the game and collide with the power up

So you can see the collision is still there, but the boost has just been hidden for 4 seconds (cool down)

Set the jump value back to the defaults

Regular jump 600

Boost 1500

compile

save

Open up your blueprints folder

Drag some coins on the way to where you want the player to go (to the end of activity 3)

*** You will need to add another power boost *** to get to the top of destination 3

 Let's look under the hood of the coin blueprint

In your blueprints folder, double click the coin and your blueprint editor will open

So this blueprint is sending information to the game mode where it is stored

When the character collides with the coin, the coin count will be accessed, one will be added and the set coin count will be set

***The coin info is stored with the game mode, not the character because if the character dies, it gets reset and your coin count will be wiped out***

This is similar to the high score in arcade games

Destroy Actor removes the coin from the game. This is different than the power boost because we want the powerboost to return after the cooldown

Let's compare the sound nodes of the boost (left) and the checkpoint (right)

A reason you would want to use play sound at location versus play sound 2D is for multiplayer games.

If someone is at another side of an open world, it may not matter to them that you got a jump boost and random sounds for no reason could be annoying right? OR Maybe you don't want the other player to know you just got some sort of boost or weapon. Which one you use should be for a specific reason.

Now we are going to create a variable from your ADD + 1 Coin node

Right click on the 1 and select Promote to Variable

Now you will see a New Var Node connected to the Add +

Change the name of the variable to something likeaddedcoins or coinsadded or whatever you like by right clicking on the name in My Blueprint and selecting rename

This variable is called an integer

The difference between an integer and a float is that a float has a decimal point

Once you have done this, compile and save

 Once you have compiled, you can now change the value of the coins added so you can make each coin worth 5 for example

 Now you need to make it public so it can be modified in game

You so this my clicking the closed eye to open on the left side under My Blueprint or by clicking Instance Editable in the details panel

Either way works and if you click one, the other changes with it.

Make sure this is selected

Compile and got back into the world

Now you can modify the value of each instance of the coins in the world

Some can be worth 1 and some can be worth 10 or whatever you choose

Save your work!