2/12


Start your day with a warm-up


Imagine your high school career was a four level video game, Fresh, Soph, JR & SR.


Tell me the storyline and game play for each level... power ups, bosses, puzzles, goals, easter eggs, etc.


What are you learning?

Packaging up the game for distribution


Why is it important?

We use conditional statements to make something happen if the criteria is met like having a key to open a door 

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

Complete lesson 5


Download and install Visual Studio  Community 2022

https://visualstudio.microsoft.com/

Click on the link below and follow the directions... double check to make sure you have done it correctly

https://docs.unrealengine.com/5.3/en-US/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine/


Open the BP_Key_activity_4_end blueprint

So here we have the info casting to the game and it's telling the game that the player has the key because the Have Key? is checked

Connect the output of the Set Have Key tot the Set Color and Opacity of the Key image that shows up in your HUD (heads up display)

The HUD is kind of like the UI Layer in GDevelop

When we click the color and opacity box in Set Color and Opacity, a color picker comes up

The RGB are all set to 1

The Alpha Channel is also set to 1

The Alpha Channel handles transparency aka opacity aka see throughness (is that even a word?)

So 1 means that you can't see through it at all, it is a solid color

So let's take these nodes and copy them

Then paste them into the BP_Key that you made

The W HUD Ref is the Heads Up Display (the UI) which is then connected to the Material (the key)

Connect the Set output to the Set Color and Opacity Input

Connect the output of the Set Color and Opacity and connect it to the play sound input

Compile, Save and Test

Now when you collide with the key, it shows up in the left corner of the game

Let's go back to our Door Locked Activity Blueprint

Notice that the code looks almost the same as the code we just coped and pasted into the Key Brueprint?

 The only difference is the alpha channel is set to 0.3 instead of 1 so it is 70% see through

This information is getting cast from the game as soon as the E is pressed

When you originally collide with the key, it shows up with the Alpha Channel at 1 meaning that is is not see through

and then when you press the E, it sends the info to change the key out to the .3 alpha and it is partially see through

Let's take a look at the Heads Up Display or HUD open up BP_HourOfCode_Game

When the game is deployed, creates the W Hug Widget (the W just stands for widget), you can see them in the widget folder in the content drawer.

Then it is setting a variable for this widget that we can use later and finally showing up in the viewport (in the game)

This has been running the entire time but we never used it until we started on the key

Open up the widgets folder in your content drawer

In the hour of code game blueprint, it references the W HUD Widget

This is where it is

Open your W HUD Widget

This is your HUD

This is only a 2D workspace

The Hierarchy is everything that is inside the hud

You can switch from designer to graph

Details panel

Screen

 boost, coins and gems are all set to invisible

Select the key in the hierarchy 

There is a green box where the key is placed

Look in the details panel for appearance > Color and Opacity

Notice your alpha channel is set to 0 so it is completely see through

Change the alpha channel to 0.3 and test the game

Compile, save and test

Drag a jump boost into your world

Go back to the HUD blueprint

Select the jump boost in the hierarchy 

Change the opacity in the alpha channel to 0.3 just like we did with the key

Now the key should show up

Compile save test

Open your jump boost blueprint

Connect the output of your Play Sound at Location node to the input of the tiny node that reads Connect Me to Play Sound at Location

We are rerouting the code

Now we are casting to the game

connecting to the jump boost in the HUD

setting the Alpha Channel to 1 (Not see through)

 

After the color and opacity are set, we add the 4 second cool down then make the boost invisible

Setting the collision back on after the cool down then changing the opacity back to the original 0.3 so that it goes back to showing up on the screen as partially see through

Next it checks to see if the player is still alive and finally changes the jump velocity back to 600

Compile, save test

It should now be opaque until you touch the boost then go full color for the cool down time and switch back to opaque

When we modified the blueprint, we created a bug

Make sure you have a checkpoint in your scene

Play the game, hit the checkpoint, get the boost then jump off the side

Notice when you respawn, the boost is not opaque even though you can't jump high.

Open the character blueprint event graph

What this is saying is that when the player hits the killZ that we set up, the player is destroyed (dead)

We are connecting that to the input that is being cast to the game by connecting the nodes

It is then setting up the color and alpha channel to .3 opacity

A player may not even notice this bug but this code is making sure that they don't

This basically resets the opacity on the key in the hud when a player dies

 Compile, save and test

Bring a coin and gem into your world from the blueprints folder

Open the HUD Widget

Select the Coins and Gems in the hierarchy

Change the Alpha to 1 in the Details panel because we want to see them all the time with zero opacity

Compile, save and test

When you collide with the gem, it counts them but it does not work with the coin

Open up the coin blueprint

When the player collides with the coin, we send info to the game

It checks how many coins are stored in the Coin Count Variable then add a coin to the value and sets the number 

Once the coin is set, we can see the output is going straight to the play sound and not updating the coin count in the hud

Connect the output on the set to the input on the Update Coins HUD node then connect to play sound 

Compile, save and test from the beginning

take some time to add some gems into your game and make it better

Open up your game completion widget from your widgets folder

In the hierarchy, we have an image that is at 50% opacity covering the screen

End Game Text reading Congratulations

This is just drag and drop from the palette on the top left

You can find more info on UMG (Unreal Motion Graphics) here https://docs.unrealengine.com/5.0/en-US/getting-started-with-umg-for-unreal-engine/

Select the time to complete in the hierarchy and notice in the top right, Is Variable is checked

This means that the text is actually a variable

Switch from Designer to Graph Mode

Time is the variable

We are converting the Timer to text, Append is updating the time, String just means text In Text means it is being actually displayed in the text in the HUD

Check out the Get Coin Count

Notice the variable

Check out the Get Gem Coin Count

Notice the variable

Debug tricks

Open the character blueprint


Check out the jump boost in the debugging area

If I connect the J pressed output node to the flip flop, a can switch from 1500 to 600 jump velocity so I can easily check to see if the player can make a specific jump

If you package the game with this code connected, it wil be a part of the game, something to keep in mind

When connected,pressing the K key will kill the player

This can be used so you don't have to keep jumping off the side to test

This escape key to quit game node allows you to quit the actual game by hitting ESC

The preferences are Quit the game while the background option is for mobile phone games to quit to the background


You MUST do this one

Compile &  Save

Time to package it up

If you did not follow the directions from the Unreal visual studio link, this will not work so you will need to modify your VS settings

Click Platforms> Packaging Settings


Change the Build Configuration from Development to Shipping

Click full rebuil;d because it is the first one and not an update

Click Description and fill in what you wish

Next click Maps & Modes

Select the map you wanted to start up (the Level_HOC_world

Click Supported platforms

We didn't add mobile controls so you can't play the game on a phone

Target hardware for the settings of the game

Go to platforms>windows and make sure to change the splash screen to something you like

You can hover over them to see the sizes

Go back to the viewport

click platforms>windows>shipping 

click platforms>windows>package project

Choose where you want the game to be saved

pack it up

Blueprint has a Capsul Collision and a Static Mesh that is a Spike

Adding a respawn

In the Game Mode Blueprint

Righ Click in the Event Gaph and add custom event

Name the custom event Respawn Player

Under Inputs in the details panel, click the +

Name the input Player