2/28


Start your day with a warm-up


You see that layoff are pretty prevalent in the industry right now. If this class was a game studio, do you think you would be one of the people who got a pink slip (lay off notice)? Think about your entire year so far including proof of work, warm-ups, pro dress, attendance, attitude, language (profanity) in class and general attitude.


Tell me why you would be kept or let go.


Explain your reasoning in detail




What are you learning?

Weapon System, changing animations, importing meshes.


Why is it important?

This is the start of everything. We are building a game so it is important that you follow along. If you start going on your own and fall behind, it is unfair to stop the class because you chose to do your own thing. If you are confident that you know what you are doing, I have no issues with you moving on your own but you will be held accountable for the project.

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

Follow along and build the game.

Grab this animation and copy it to your desktop

Compile save test 

Open your montage and scrub to where the attack actually happens

I am choosing .26

Back to the Enemy Event Graph

Add the .26 to your delay

Compile, save, test

Start of lesson


Open up your ThirdPerson BP Event Graph in the health system

Remove the connection from the branch to set silulate physics

Add Destroy Actor

Compile, save test

It's not working!!! I am not happy

Open up the ThirdPersonCharacter BP

You can see that after we subtract one, nothing is connected

Connect it to the Set

Compile, Save, test and play

Okay we can die now but we are not respawning

Open the Level Blueprint

In your level blueprint event graph, add a custom event

Name it Respawn

Add a 2 second delay

Add Open Level (by Name)

Add your level name

Compile Save 

Go to your level and find Game Mode in your World Settings

In GameMode Override

Set your Selected GameMode to BP_ThirdPersonGameMode

In your content drawer, open Content>Thirdperson>Blueprints>BP_ThirdPersonGameMode

Click Open Full Blueprint Editor

Copy the Respawn Delay and Open Level (by name) nodes in your Level Event Graph

Paste it in your BP_ThirdPersonGameMode Event Graph

What we are doing here is making the respawn in the game mode so that we can reference it in the Character Blueprint

Open the third person BP

Break the link between the branch and destroy actor

From the True output in your branch

Add Cast ti BP_ThirdPersonGameMode ** MAKE SURE IT'S THE GAME MODE!!!**

Pull out the Object input from Cast to BP_ThirdPersonGameMode

Add Get Game Mode Node

Connect GameMode output to Destroy actor

From Cast to BP_ThirdPersonGameMode output, pull out Respawn

Connect the As BP Third Person Game Mode Output to Respawn target

Connect respawn to destroy actor

Compile, save test

We are going to use the different animations for when we get hit

Open up your AnimStarterPack folder in the content drawer 

Seach HIT

Select them all

Right Click

Select Retarget Animation Assets

Duplicate and Retarget Animation Assets

Select the RTG_UE4_UE5Manny

Drag the Aminations into your Shotgun Animations Folder select move

Open the Shutgun Animations Folder

Create a new folder called Hit_Anims and move your Hit Animations into the folder

Open the Hit_Anims Folder

Select all four animations

right click

create

create animMontage

Open ThirdPersonCharactr BP event graph

Add a new variable and call it hitAnims

We are going to change the variable

Search for Anim Montage > Object Reference

Compile

In the details panel change the variable type to array because we want multiple
Array is a collection of variables all stored within a single unit. 

Click Compile

In the details panel under Hit Anims, click the plus four times and select seach animation

Compile

Go back to the thirdperson event graph

Drag in the hitAnims Array into the Health System Area

We want to GET the info

From the hitAnims

Pull out Get (a copy)

From the green input in Get, pull out Random Integer in Range

The Minimum will be 0 because that is our first animation

***We can make the maximum 3 if we don't plan on ever adding additional animations***

Drag in the hitAnims and select Get hitAnims

From the Hit Anims that you just added, pull out a Length Node

Connect the output to the Max Input of Random Integer in Range

This will add the last number on the list of variables

Break the link between Spawn System at location

From the output of Spawn System at location, pullout a Play Anim Montage Node

Connect the Get output to the Anim Montage Input in Play Anim Montage

Compile, save test

When we take damage, the same animation doesn't play over and over again

Door

We are going to create a door Parent that can be used to Open and Close any of the Child Events (remember the parent and child in Blender?)

Open your Content Drawer add a new folder called Doors

Open the folder 

Right click>Blueprint class >actor

Open the BP_Door_Parent

Add a Static Mesh from the components tab on the top left and name it DoorFrame

Add a second static mesh and name it Door

Compile and Save

With your DoorFrame Component Selected, search for a door frame in the details panel under static mesh and select

Select your Door Component and search for a door in your details panel under static mesh

Move the door so that it fits in the doorway (You may turn off snapping if you want to be precision)

Compile and Save

Open the Event Graph for BP_Door_Parent

 Right Click and add a custom event and name it OpenDoor

Right Click and add a custom event and name it CloseDoor

From OpenDoor pull out Add Timeline

Add a Timeline and call it DoorAnimation

Connect the Open Door event to Play

Connect the Close Door event to Reverse

Double Click on your DoorAnimation Timeline to open it up

Change the length to half a second 0.5

Click on the +Track and add a float track

Name it Door_Alpha

add Two keyframes (Right Click in the timeline) 

Add the first on time 0  and value 0

Add the second on time 0.5 and 1

Select both Keyframes by shift click

Right Click  and select User

Compile and Save

Return to the Viewport of your Door Animation and Select the door

Select the rotate Button

Click and Hold the Blue Area to rotate the door  open

Rotate it and notice the degrees then rotate it back (we will set it at -110 Degrees

Go back to the event graph and add the door component to the graph

Pull out a link from the Door Component and add SetRelativeRotation (door)

Connect Update

Pull out a LERP from New Rotation to rotate

Connect the Door Animation Timeline to the LERP Alpha and Check the Shortest Path Box 

Change the Z Value of your B LERP to -110 (The rotation of your door)

Create a Comment to Group

Compile and Save

Opening the Door

Child Blueprint and overlap

In the Blueprint for the Door Parent, select the Default Scene Root in the top left

The door is currently too small for the player to fit through so we need to increase the size

In the details panel  under transform, change the Y Value (Green) to 1.5 and the Z valuer (Blue) to 1.3

Open up your content drawer on the bottom left

Select your doors folder in Bluerprints

Right Click on the BP_Door_Parent

Select Create Child Blueprint Class

Name the Child BP_Door_Overlap

Double click to open it up

The goal is to get the door to open when we get close to it

To do this, we need to add a collision

Click on the +Add under components and add Box Collision

We will make the box collision pretty big so that we can get it to work at a distance

In the details panel, change the shape to X= 400 Y = 250 and Z = 200

Then move the box collision so it is around the door

Find collision in your details panel

Make sure Generate Overlap Events is checked and Collision Preset is on OverlapAllDynamic 

Find events on your details panel

We will create ab event by clicking the + On Component Begin Overlap

This will open up an Event Graph and add On Component Begin Overlap (Box) Node

Select the Box in your components and then Click the +  in Detail > Events > On Component End Overlap

You should now have two events on your event graph

One for begin (open) and one for end (close) when the player gets to the collision

In the begin node, pull out a link fr om Other Actor and add search for == to get the = Node

Right click on your Event Graph and add Get Player Character Node

Connect the return value  of the Get Player Character Node output to the Select Asset Input in the = Node

Add a branch

Connect the Output of the == Node to the Input Condition of the Branch

Connect the output Exec from the Begin Overlap to the input Exec of the Branch

What's happening here is that we are setting up the door to open when the character hits the collision box

From the Branch, pull out a connection from True and add Open Door Node

Copy and paste the Get Player Character, == and Branch Nodes then paste below

We are doing this so the door will not close if another Pawn (NPC) leaves the area. We want it to only trigger for the character.

Connect End Overlap Excec output to exec input of the new branch

Connect End Overlap other actor output (blue) to the unused input of the ==

From the branch connected to the End Overlap, pull out a new connection called Close Door


Compile, save, drag an instance of your BP_Door_Overlap into your game then test

Pressure Plate

Creating an actor that will work as a pressure plate that will open a door

Open your content drawer and open doors folder then right click and create a new blueprint Class Actor

Name it BP_PressurePlate

Double Click to Open the Event Graph 

Add a static mesh component in the top left corner

Name it PressurePlate

 Select your PressurePlate Mesh and in the Details panel on the right side under static mesh, select cube

In the Details Panel under Transform > Scale, change the Z from 1.0 to 0.1

Compile

Add a Box Collision in your components (top left)

Make it fit around your pressure plate

Look for Collision in your details panel

Make sure Generate Overlap Events is checked and Overlapalldynamic is selected in the presets

This makes anything that lands on top of the overlap will start an overlap event

Compile and Save

Under Events in the Box Details Panel, add the event On Component Begin Overlap

then select the box again and add the On Component End Overlap

(We have done this before)

**Important**

There is no Open Door Node in the Parent Class


We need to create a variable to deal with this

Create a new Variable and call it Door_Reference

In the details panel, change the variable type  to BP Door Parent

Set it as an Object Reference

This will allow you to set a level instance of a door and set it as a reference

Make sure to make the instance editable by checking the box so we can select a door in the world

Compile and Save

Drag out your door reference and choose Get

From your Door Reference Node, pull out and add Open Door

Connect the Exec from the Begin Overlap to the Exec to the Open Door Node

Drag the Box Collision in the graph (Get)

Add Get Overlapping Actors

Click on Class Filter and select Actor

What we are doing here is making sure that any actor is the one closing the door and not something that happens to fall on the trigger

We are creating an array (list of actors that are overlapping)

From the overlapping actors node, pull out the blue output for overlapping actors and select Get (a copy)

Pull out from the Output of your Get and select Is Valid? MAKE SURE YOU USE THE ?

From the Exec of the End Overlap Box, connect to the input of the ? Is Valid Exec

Change the GET # to 1

This will ignore the Zero Result (character) and checks for the next actor (cube)

From our Door Reference Node, pull out an add Close Door

Connect the Is Not Valid Exec to the Exec Close Door

So if an actor overlaps (collides) with the box collision. the door opens and only the actor will close the door

Compile and save

Go back to your First Person Map and Drag a Door (BP_Door_Parent)  in the game

Add a Pressure Plate and select it

In the Outliner Panel find Door Reference

Choose BP_Door_Parent

Compile, Save and Test

Let's create a box in blueprints.

Right click > Blueprint Class > Actor

Name it BP_Box

Open it

In your BP_Cube Blueprint

Add a cube in y9our componenmts

Find Physics in the details panel

Select physics

Click Simulate Physics

Click mass

Chance the mass to 35kg (so you can actually move it)

Go to your game map and stack some boxes near your pressure plate so you can knock them down and make the door open

Compile, save and test

Make sure the box can open the door

Light Switch

Right click > Blueprint Class > Actor

Name it BP_Lights

Open it

In components, add a cube (we will make a little platform)

Add lights

Add > Point Light (We want this to be a child of the cube this time)

Change the color and increase the intensity

Add a second point light and make it a different color

Make sure it is a child of the cube and not the first point light

Add a box collision to your cube and make it fit the cube

Open your event graph

From Event Begin Play, oull out Set Visibility (Point Light)

Click new visibility on (make it true.... booleans baby!)

Pull out a delay from set visibility

Make it 1 second

From our delay, pull out another set visibility (make sure it is on the same point light you used)

This time do not check the new visibility box so it is false

Add another delay

Now we are going to make a look so it keeps going 

From the output of our delay, pull out the node and connect it to the input of the original set visibility

If you want to pull out and make the node wider so it is easier to see, just double click it then pull it out

Compile Save Drag your Light Box in the game map and test


Next go back to the event graph and break the lnode from event begin play to set visibility

From Event Begin Play, add a Flip Flop

Flip Flip will alternate the actions A & B

Connect Flip Flop A to Set Visibility

Now we are going to duplicate the nodes we created for our first light by copy and pasting then change the name to our second light

Notice that once it finishes, it loops back to Set Visibility and not Flip Flop. We need to break the link and connect them to Flip Flop to complete the loop properly

To do this, right click on the Set visibility input and hover to Break Link to Reroute Node

You will also need to do this for the final delay on order to connect it to the flip flop node.

Compile, save and test

Time to make a health bar

Open your content folder and add a new folder called UI then open it

Right Click

Select User Interface > Widget Blueprint

Select User Widget

Name it WB_HealthBar for Widget Blueprint and open it

In the WB_Healthbar

Search for Canval Panel in the palette

Drag it into the Healthbar Hierarchy

In palette, search for Progress Bar and add it to the workspace in the top left corner

Change the color to red or whatever you wish

You can preview the color by adding a number to the Percent in the progress in details

We are going to place the anchors by clicking on the flower/pinwheel type thing

We do this so the bar stays put no matter what the screen scale is set to

In the progress, add 100 opercent and click bind

This will create a widget that will send/receive info

From the Get percent, pull out asnd add Cast to BP_ThirdpersonCharacter

From the Object add Get Player Character Node

From the As BP Third Person Character output, add Get Health Variable

From the health pin, we needf to add a divide because we need the health hits to be proken up sp that it takes off a portion of the progress bar depending on the number left in the variable.

You need to make sure the number you gave for health in the BP_ThirdPersonCharacter is the number you are dividing by

Connect the green output of the divide into the return value

Compile, save

Open your BP Third Person

Find the Add Input Mapping at the top of the Event Graph

Pull out a Create Widget Node from Add Mapping Context

The Class will be WB_healthbar

From the Owning Player input, pull out and add Get Player Controller