Introduction
Welcome to GDD310!
In this course we will begin learning how to utilize the Unreal Engine to develop games. We start with an exploration of the editor interface and various
tool available inside the development environment. The course is broken into five Assignment Sets, each designed to introduce a core element of
Unreal Engine game development and provide a framework for students to explore bringing their ideas to life.
Assignment Set Topics
- Construct a Maze: Learn how to navigate the editor and create basic level geometry. Explore Unreal Actors.
- Adding Materials, Light, and Sounds: Learn how to create and apply materials to level geometry, control lighting, and play audio effects.
- Blueprints: Introduction to Unreal's visual scripting tool.
- Landscapes: Create new worlds for your games.
- User Interface: Create a dynamic and interactive UI.
The lessons learned in this course will serve as the foundation needed for a career in Unreal Engine development for programmers and artists.
Final Project
After the Assignment Sets are complete, the class will begin the design phase of the final project. Students will form teams and create a new game using the Unreal Engine.
Learning Objectives
- Students will:
- Learn how to navigate the Unreal Editor.
- Practice creating levels and adding functionality to actors in their games.
- Learn how to work with materials and lights and use the material editor.
- Create Blueprints and use the visual scripting tool to add logic to their classes.
- Create a complete game.
Introduce Yourself
- Let us know who you are, why you're here, your experience in game development, and the area of game development that you're most interested in
- Show off or discuss anything you've made in the past
- Tell us your favorite game/genre
Getting Started
- Review the course syllabus and grading rubric.
- Download and install Cyberduck to connect to MyWebspace FTP . Instructions on how to connect
- Cyberduck will allow you to copy files from your computer onto a server so that they can be viewed from the internet. This is how you will share your work.
- Note when connecting: User name "mywebspace.quinnipiac.edu|QUUsername" (there is a pipe before you enter your QU Network Username)
- Create a portfolio for this course. Here are a few options.
- Create your own (HTML/CSS/JavaScript)
- Copy this example portfolio to your computer and change the HTML to display your name.
- This website will host links to all of your work. When you build an exercise or project it will generate a webpage. The links on this portfolio will point us to your builds.
- To save the page: Open the page > right-click on the background > select Save Page As. Create a folder on your computer for your course work, ex: c:/GDD/GDD310/Portfolio and save the webpage in there as index.html.
- Open your portfolio in a text editor so you can change the HTML to work for your account. Use VSCode if you need a text editor.
- Change the name at the top to your page and change the username cblake inside all of the links to your username. Ex:
<header> <h2>Lab 1</h2> </header> <section> <nav> <ul class="lab_links"> <li><a href="yourTrelloURL"target="blank">Lab 1 Project Management (Trello Example)</a></li> <li><a href="https://mywebspace.quinnipiac.edu/yourUserName/buildFolder">Lab 1 WebGL Build</a></li> <li><a href="yourGitHubURL">Lab 1 GitHub Repo</a></li> </ul> </nav> <article> <h1>Example Lab 1 Project</h1> <img src="http://mywebspace.quinnipiac.edu/yourUserName/imageName.gif"style="width:200px;height;200px;"> <img src="http://mywebspace.quinnipiac.edu/yourUserName/image2Name.gif"style="width:200px;height:200px;"> <p>Description of your game!</p> </article> </section>
- You can now upload a copy of your portfolio to MyWebspace. Inside CyberDuck make a directory called 310, and drag your index.html file into it. To make sure it works you can try clicking the link to your name in the Student Work section or navigating to: http://mywebspace.quinnipiac.edu/username/310/
- This is the most basic example of a working portfolio, I encourage you to explore HTML, CSS, and JavaScript to make it look more interesting!
- Use Canva Template
- Open template here. You will need to create an account and save a copy of the portfolio for yourself.
- Edit the portfolio to include your name, the course title, and your work.
-
Save your Canva as a website
Share > More... > Website > Standard - Email me the URL for your website so I can link your name to it on the Student Work page.
- Install
Epic Games Launcher . This launcher will allow you to install and manage the Unreal Engine software. (Help with installing Unreal) - Launch the Epic Launcher and Install Unreal Engine 5.
- Join the GDD
Discord Channel and introduce yourself. This is a place for GDD students to stay in touch outside of the classroom. Ask questions, help each other.
Assignment Set 1 Lecture Recording
Constructing a Maze
In this assignment set, we will begin learning the Unreal Editor and it's various tools, editors, and windows. We will be utilizing a game
template so that we can move around and interact with our game world, and then design a maze for our players to explore.
Consider using GitHub Desktop.
- Ready to go?
- We will make sure everyone has completed the tasks assigned so that every student is ready to begin working with Unreal.
- Starting a new Unreal project
- We will be starting our Maze project by using a template. This will create a new project that already has some basic functionality working, like walking around in a first-person perspective.
- 1. In the Epic Games Launcher click Launch Unreal Engine.
- 2. When the Unreal Project Browser opens, in the GAMES tab, select First Person Template and create a new project. Select the path to your
Unreal projects on your machine and give your project a name.
- 3. Your new project will now open in the Unreal Editor!
- 4. Explore the Unreal Editor
- 1. Menu Bar
- 2. Main Toolbar
- 3. Level Viewport
- 4. Content Drawer
- 5. Button Toolbar
- 6. Outliner
- 7. Details Panel
- 5. Create a Level
- Create a new level ( File > New Level > Empty Level > Create )
- In your empty level, add a cube.
- To see your cube in a level without light, set the render mode to Unlit. This only changes the lighting in the viewport, not a build of the game.
- With your cube selected, press the General button in the Details Panel to view begin editing the properties of the cube. You can stretch the cube in the
X, Y, and Z, directions. Remember: Z axis is up/down in Unreal!
- Next add a light to your level. If your Place Actor window is not visible, go to Window > Place Actors. Now, in the lighting tab of the Place Actor window,
select a Point Light. Drag in onto the cube to place a point light in your scene.
A point light acts like a light bulb in your scene, emitting light in a sphere around the light's position. Try experimenting with other lights to see how they behave.
-
We're ready to add our player to the level. In the Place Actor panel, find the BASIC tab. Drag a Player Start actor onto your cube. Press the PLAY button
in the Toolbar to begin playing your level.
- 5. Create your first Blueprint Class
A Blueprint is a container for components and scripts. When creating a Blueprint, you will inherit from a base class, and then build additional functionality on top of it. Often, an Actor base class is the start of new Blueprints, because it allows you to place instances of your Blueprint in your level. - Open the Content Drawer in the Unreal Editor.
- Create a new folder for your Blueprints: "MyBlueprints", and open it.
- Click the "+ ADD" button on the Content Drawer to view the Add options. Select the Blueprint Class. (You can also right-click inside the Content Drawer to open the same menu.)
- Here you can select the base class for your Blueprint, choose
Actor . - You should see a new Blueprint in your folder. Double-click on the Blueprint to open the Blueprint Editor.
- Inside the Blueprint Editor's Viewport you can see what you Blueprint looks like.
Assignment Set 1 Project
You must create at least 1 Blueprint and use it in your maze at least 3 times. Consider using a Blueprint for anything that gets used more than once, which can occur frequently inside a maze.
Remember to include all of the required content detailed on the grading rubric page.
Assignment 1 Example: Climb the towers to get to the exit. Navigate the small platforms and ledges to find your way to the top. Don't fall or you will need to start over!
Towers are a Blueprint , making it easy to build out more towers and iterate on the level design.
Assignment Set 2 Lecture Recording 1 Lecture Recording 2
In this Assignment Set we will cover:
Adding Textures
Creating Materials
Using Quixel Bridge to Import Assets
Lumen Engine and Lighting in Unreal
Playing Sounds
- Project
Unreal engine is capable of creating stunning visual elements for your games, and provides various tools and editors to help your game look great.
We will be exploring how to use all of these features of the Unreal Engine to empower you to deliver the visual experience you are imagining.
Adding textures to your project
-
You can often find high quality textures in online collections like at Textures.com
To start downloading textures from Textures.com, create a free account and then find the PBR Materials collection.
Find a material that you like, and then download the textures associated with it to your project's Content folder. - When you return to the Unreal Editor you will be asked if you want to import the new files into the project, select import
- You will now see the new textures inside your content browser. You can double click to open a texture in the texture editor window and adjust any properties you need.
Creating new materials
- To create a new material, make a Materials folder inside your content browser. Next, click the ADD+ button to add a new material. Double click the new material to launch the material editor.
- The material editor uses a node based editor. Stringing together nodes and plugging their output into a material channel of the final node generates our final material.
- You can choose the material properties by selecting the final output node and looking at the Material Domain and Blend Type. If you require some of the material to look invisible, like holes or glass, you can choose the Translucent Blend Type.
-
To create a simple color tint, expand the palette along the right side of the editor, and select a
Constant Vector 3
. This node outputs a color based on the values of it's X, Y, and Z, properties. Try double-clicking the black square of the node and changing the color to something else. Then plug the output of the node into the base color pin of the final node.
-
Too apply our textures to the material, create Texture Sample nodes for each texture. You can drag textures from the Content Drawer into the graph to
automatically create a Texture Sample node with the texture filled in.
-
When applying your material to a mesh, you may find that it is scaled too large or too small on different meshes. You can create
a material instance to allow you to modify properties of the material for only that instance, while maintaining the rest of the master materials
properties.
-
In order to enable texture scaling for your material instances, the master material needs some additional nodes.
Add aTexture Coordinate
node,Const
node, and aMultiply
node.
Next, promote theConst
node to a parameter, making it editable in the material instance editor. Name it "Scale" and set the default value to 1.
Now, we can open the material instance we created and modify the scale parameter.
To enable independent scaling on X/Y axis, we can create a separate parameter for each axis.
Append
the parameter outputs before connecting them to themultiply
node.
-
Try experimenting with some of the other nodes!
Importing Quixel Assets
-
Quixel Bridge allows you to browse and import ultra high quality Megascan assets right from the Unreal Editor. These assets are free to use in Unreal Engine only.
-
- Unreal 5: Simply open a Content Browser, select the ADD button, and click "Add Quixel Content".
- Unreal 4: Download Quixel Bridge and install. - You can browse assets, select a quality level to download, and add to your project. The assets will appear in your Content Browser.
Lighting and Lumen Engine in Unreal 5
Image from Unreal Engine Documentation
- The Lumen Engine provides unlimited realtime diffuse light bounces, allowing scenes to glow with realistic color.
- To place a light in your Unreal level, find the Lights page of the Place Actors window and select
a Point Light. You can adjust the settings of the light in the Detail panel.
Adding Sound to Your Game
-
Unreal Engine will only play
.wav
audio files, so you will need to convert.mp3
files. You can use Audacity if you need a free tool to do so. - Import the audio asset into your project. If you need to find music or sound effects for your game, take a look at the Resources page.
- Playing A Global Sound
-
To play a sound everywhere, like with background music or a narrator speaking, you can play it using a
2D node. We will explore how to play a sound in the Level Blueprint, but this could also be done in an
actor of your own making.
-
Inside the Level Blueprint's Event Graph, right click and add a
Event BeginPlay
node. This node will start calling functions when the level begins.
-
From the output of the Event BeginPlay node, drag a line and release it to select a connecting node. Choose the
Play Sound 2D
node. This node will play the sound selected in theSound
field of the node. The 2D Sound is played directly to the players camera by default, so you should hear your sound when you start the game.
- Playing an Ambient Sound Effect
-
To play a sound effect from a position in the level we can
create a new Blueprint. In the content browser, add a new Blueprint, which
inherits from
Actor
. - To control the sound attenuation you will first want to create a Sound Attenuation asset in your content browser. This settings on
this asset can be used to control the audio effects of your sounds, like how far away they will be heard.
- In the new Blueprint, open the Event Graph window. Drag a line off the
Event BeginPlay
node and select thePlay Sound At Location
node to create the node and connect them.
Drag a line from theLocation
pin on thePlay Sound At Location
node and add aGet Actor Location Node
to set the location property to the location of the instance of this Blueprint in the level.
Next, select the sound you want to play from theSound
property drop-down menu.
Be sure to set the sound attenuation setting of the node to your Sound Attenuation asset, click the down-arrow on the bottom of the node to expand the properties.
- Playing an Sound Effect On Trigger
-
To enable a trigger to play a sound effect we're going to create a New
Blueprint, which again inherits from
Actor
class. -
In the Viewport window of the Blueprint Editor, add a
Box Collision
andCylinder
component. Flatten the cylinder so it rests on the ground, and place the collision box over it so we can enter it when we step on the cylinder.
-
In the Event Graph Window, we want to use the
Event ActorBeginOverlap
node to start our sound when the player enters our collision. We'll be using something calledCasting
in this script to verify that the actor which hit our trigger was the player.
Be sure to set the sound attenuation setting of the node to your Sound Attenuation asset, click the down-arrow on the bottom of the node to expand the properties.
Assignment Set 2 Project
You should create and apply at least 3 materials.
You should add at least 3 lights.
You should have at least 1 sound effect that is played by a trigger. Remember to include all of the required content detailed on the grading rubric page.
Assignment Set 3 Lecture Recording 1
In this Assignment Set we will cover:
Blueprint Basics
Doing More With Scripts
Components
Reference Another Actor
Creating Custom Events
Moving Actors with Timelines
Building a Moving Platform
User Input and Spawning Actors
Project 3
Unreal Engine provides a method of writing scripts for your games using a visual scripting system. Events call functions and follow a path outlined
on graph, weaving a series of nodes into the functionality behind your game. Visual scripting allows you to easily navigate script execution flow
through each node, where you can reference variables and utilize common programming features like collections and loops. We will learn how to get started
with the visual scripting system by creating interesting game elements for our maze, and then you will build your own unique blueprint from the ground up.
Blueprint Basics
-
To start writing your Blueprint script, open a Blueprint and navigate to the Event Graph window of the Blueprint editor.
-
The default events of a new Blueprint are automatically laid out on the event graph. To enable these events, you must add functionality by adding a connected node.
We can add a node to an event by clicking on the Exec
arrow on the right side of the event node, and dragging a line off of it. When you release the mouse, a
window will let you select which node you wish to add at this position. You can type to filer through the available nodes. Try typing "print" to locate the Print
node.
Event BeginPlay: This event gets called when the game starts.
Event ActorBeginOverlap: This event gets called when the actor (the instance of this Blueprint in the game) makes contact with a collision.
Event Tick: The event is called with each frame of your game.
-
To add variables to your Blueprint, use the ADD button on the My Blueprint panel, and select Variable. You will see a new
boolean
variable added to
the Variables list on the My Blueprint panel. You can give your variable a name, and change the type. Select your variable and edit it's properties in the Details
panel.
-
To reference a variable in a function, drag the variable onto the graph and choose "Get" to add a node that will read the value of the variable. You can then plug the output from
the node into another nodes input.
-
Blueprint Cheat Sheet from Unreal Documentation
Blueprint Basics
-
To start writing your Blueprint script, open a Blueprint and navigate to the Event Graph window of the Blueprint editor.
-
The default events of a new Blueprint are automatically laid out on the event graph. To enable these events, you must add functionality by adding a connected node.
We can add a node to an event by clicking on theExec
arrow on the right side of the event node, and dragging a line off of it. When you release the mouse, a window will let you select which node you wish to add at this position. You can type to filer through the available nodes. Try typing "print" to locate thePrint
node.
Event BeginPlay: This event gets called when the game starts.
Event ActorBeginOverlap: This event gets called when the actor (the instance of this Blueprint in the game) makes contact with a collision.
Event Tick: The event is called with each frame of your game. -
To add variables to your Blueprint, use the ADD button on the My Blueprint panel, and select Variable. You will see a new
boolean
variable added to the Variables list on the My Blueprint panel. You can give your variable a name, and change the type. Select your variable and edit it's properties in the Details panel.
-
To reference a variable in a function, drag the variable onto the graph and choose "Get" to add a node that will read the value of the variable. You can then plug the output from
the node into another nodes input.
-
Blueprint Cheat Sheet from Unreal Documentation
Doing More With Scripts
-
To evaluate a condition in your script (create an "if" statement) and have branching paths, you can use a
Branch
node.
-
If you want to connect multiple strings you can use the
Append
node. Note: To print on another line in the console press "shift+enter" in the string field to move to the next line.
-
To make an array, create a variable of the type of data you want. Then, in the details panel, convert the variable into an array.
-
To access an element from an array, add a reference to the array and then use the Get node to select the element.
-
You can use the
Random
node to get a random number from a range. Note: You can connect the output of a node to multiple other inputs!
Components
- To reference a component in the Event Graph, drag the component from the Components panel onto the graph.
-
To add an event for a specific component to the Event Graph, select the component and at the bottom of the Details panel, press the + symbol next to the event you wish
to add.
-
To determine if our player actor is the one which called the overlap event, we can
Cast
theOther Actor
from the event to our player class. (First Person or Third Person Character)
If the cast passes, the execute line will follow the top Exec arrow. If the cast fails, the execute line will followCast Failed
.
Reference Another Actor
Creating Custom Events
-
If you want to create your own event to make repeated use easy or to be called by another actor, create a
Custom Event
node.
Here is how to call the custom event from another actor. "Target Platform" is a reference to the actor which has the custom event on it. Access this event by first dragging the actor reference onto the graph, selectingGet
, then finding the event name in the "Call Function" list.
Moving And Rotating Using Timeline
- To change the position or rotation of an actor you can use a Timeline node and the Set Actor Location / Rotation node.
-
The Timeline node can be used to change the value of a number over time, which can be passed out of the node and serve as an input for another node.
-
I've set my Timeline to change a value from 0 - 1 over 2 seconds. I can use the multiply node to scale this range to a usable number by combining it with a public float
variable that can be set in the details panel.
-
Now, add a Set Relative Location node and assign the component you want to move as the target. We want to pass the value changing in the timeline into the Z property of
the New Location input, so right-click the New Location struct and spit it into three separate float inputs. Connect the float output of your Timeline node into the Z
property of your New Location node.
Next, drag a line from the Timeline's Update pin into the Set Relative Location's execute input pin. This will run the function each time the Timeline updates the variable, causing the lift to keep moving until the timeline is complete. You can then continue your script with the Finished execute pin.
Moving Platform
-
To practice what we've learned so far, let's create a platform that can lift the player when they stand on it. The platform will begin in a locked state, and be unlocked
after the player triggers a button.
Add Components
1. What components do we need for the moving platform Blueprint?
2. What components do we need for the button Blueprint that unlocks the platform?
Define Variables
3. What variables does the platform Blueprint need?
4. What variables does the button Blueprint need?
5. Which variables can we set in the editor? How do we make it so actor variables can be set in the details panel?
Add Collision Events
6. How do we call an event when each Blueprint's collision component is contacted by the player?
Add Unlock Event To Platform
7. How does the button Blueprint tell the Platform to unlock? How do we ensure only the player can trigger it?
Move Platform
8. How do we detect when to move the platform? How do we move it?
User Input and Spawning Actors
-
To define our own input event, we can define a user input in the Bindings settings. Go to Edit
> Project Settings > Input > Bindings and add an action to the Action Mappings list.
- To start adding custom input events to your character, find the character in the World Outliner panel and select Edit Blueprint beside it's name. This will launch the Blueprint Editor for the player Blueprint.
-
In the Blueprint's Event Graph, you can now add an event for the new Action you created. I called mine "Fire"
Assignment Set 3 Project
You should use at least 2 Blueprints in your maze that the player can interact with.
Remember to include all of the required content detailed on the grading rubric page.
Assignment Set 4 Lecture Recording 1
In this Assignment Set we will cover:
Creating a Landscape
Adding Water to your Level
Adding Trees from the Unreal Marketplace
Creating a Landscape Material
Project 4
Creating levels for your game often requires more than stacking Cubes throughout your level. If you want to generate rolling hills, a daunting mountain pass, a calm lakefront camp site, or any other outdoor space, Unreal's Landscapes are the tool to use.
Creating a Landscape
- A Landscape in Unreal sits in your World Outliner, and works by deforming a mesh based on the values of a heightmap. To draw to your heightmap, you can use the Sculpt tools, which will raise, lower, and flatten, terrain as you paint.
-
To begin working with Landscapes, change the editor mode to Landscape
-
Once you choose your Landscape settings you can generate the new Landscape and then begin sculpting.
-
To sculpt the terrain, use the sculpt tools to change the height of the landscape.
-
Add foliage to your landscape in foliage mode.
Creating a Landscape Material
To paint and blend materials together on your landscape, first download two textures (albedo and normal). Example 1 Example 2
- Create a new material.
- Add albedo and normal map for both textures.
- Add a
Landscape Layer Blend
node to your graph. Select the node and add two layers. Name them "Grass" and "Dirt"
This node will combine the albedo textures for this material.
- Add a
Landscape Layer Blend
node to your graph for the normal maps, also name the layers "Grass" and "Dirt".
Then plug in the albedo and normal maps to their proper inputs.
Plug the outputs of the Landscape Layer BLend nodes into the Base Color and Normal material inputs.
Add aLandscape Coords
node and plug it into each of the Texture Sample nodes.
-
Select your Landscape actor, and in the Details window set it's Landscape Material to your material.
In the Landscape Mode > Paint menu, create aLayer Info
for each layer.
Adding Water
- Unreal features a water plugin that can be enabled in the plugins menu (Edit > Plugins > Water)
- The Ocean water actor creates the appearance of an endless ocean surrounding your level.
- The Lake water actor allows you to use bezier curves to control a body of water that can be places inside a landscape. Right-click along the edge of the lake to add nodes, select nodes or handles to adjust their position.
Assignment Set 4 Project
Consider adding vegetation, water, and other interesting elements to help create a believable world.
Remember to include all of the required content detailed on the grading rubric page.
Assignment Set 5 Lecture Recording 1 Lecture Recording 2
In this Assignment Set we will learn how to use the Widgit Blueprint to create interactive UI
Widget Blueprint
Canvas Panel
Text Widget
Add UI To Game
Widget Blueprint
Canvas Panel
Text
Creating a Player HUD
-
Unreal Game Modes allow you to
control game mode properties. To manage the various UI elements our player will need, we want to create a custom HUD class to manage the rest of our
widget classes.
-
First, create a new Blueprint which inherits from the HUD base class. I will call mine "PlayerHUDBase".
Now, in the World Settings panel, in the Game Mode overrides, set your HUD Class to the class you just created.
In the PlayerHUDBeginPlay Event
, add a Print String function and then run the game to verify that you HUD is loading. -
Next, we need a Widget to act as our first UI element. Create a new Widget Blueprint. I will call mine "Counter"
Add a Canvas Panel and a Text to the canvas. Anchor the text appropriately, and check the ☑️Is Variable
option in the Details panel. This will allow us to set the value of this text element through out script. -
To get our Counter widget to appear in the PlayerHUD, we can have the PlayerHUD create an instance of the Counter and store a reference to it.
First, add a variable to the PlayerHUD Blueprint with the type set to your Counter Blueprint. Next, we're going to create this sequence.
🔸Create Counter Widget: This is creating an instance of our widget by setting the class type and calling this function. Note that this requires an "Owning Player" to assign the widget, so we useGet Player Controller
to pass in Player 0.
🔸Set Counter: With the output from creating the widget we can store a reference to the new widget we created, so that when we need to change our count text, we have a way to reference it.
🔸Add to Viewport: This will display the widget on the screen.
Assignment Set 5 Project
You can add UI elements to your maze, such as buttons and sliders, that open doors or lower a drawbridge, for example.
You can also make a complete game from the UI, like a cookie clicker game.
Remember to include all of the required content detailed on the grading rubric page.
Assignment Set 6 Lecture Recording
In this Assignment Set we will learn how to add characters and animations from Mixamo to explore animating models in Unreal.
We will be using the Third Person Template in this lesson and changing the Third Person Blueprint's Mesh and Animations.
Add models and animations to Unreal.
-
We will be using Mixamo to download a character mesh, textures, and animations.
Select a model from the Characters list and download the model as aFBX Binary
file in the .
Save this model into your project's Content folder.
-
Next, download an Idle, Walking, and Jump, animation.
UseFBX Binary
format andWithout Skin
.
Be sure to ✅check In Place for walking animations, if available.
-
In the Unreal editor you will see a prompt for the import settings of the new assets.
For the Character model, leave the default settings and select Import.
For your animations, open the Skeleton selection drop-down and find the skeleton of the character you imported.
Animation Blueprint.
-
An Animation Blueprint controls animation behaviors.
Create a new Animation Blueprint in your Content Drawer.
-
You will need to select a skeleton for your Animation Blueprint to target. Choose the skeleton associated with the character you imported.
-
In the Animation Blueprint editor, open the AnimGraph window.
Here you can find the Output Pose node on the graph. This node represents the animation which is being played on the skeleton. We will plug various nodes into the Output Pose node to control which animation it is playing.
-
Sequence Player nodes can be plugged into the Output Pose node. You can drag an animation from your content
drawer into the graph to add one.
We wil be using a State Machine to control which animations are influencing the output.
State Machine
-
A State Machine allows for control over which animations are influencing the output.
Add a state machine to your graph. Then double-click the State Machine node.
-
Inside the state machine, right click to create new states. Create a Movement state and a Jump state.
Then, drag the Entry pin onto the edge of the Movement node, to have our state begin there.
Next, click and drag the edge of the Movement state and drop it on the Jump state. This will create a transition between the states.
Do the same from Jump to Movement.
-
Open the Jump state and add the Jump animation to the graph. Connect the Jump sequence to the Output node.
This will cause the jump animation to play when the Jump state is entered inside this state machine.
-
Now we need to enable the transition from the Movement state to the Jump state.
Open the transition going from Movement to Jump.
Enable the transition.
-
To control the transition between the Walk state and Jump state, we need to write a script in the Animation Blueprint's Event Graph
Open the Event Graph window and add abool
variable called "On Ground". The state of this variable will control when we transition between our Movement state and Jump state.
-
We can reference the ThirdPlayerBlueprint using
TryGetPawnOwner
. Then, to check the movement properties, useGetMovementComponent
. From there, we can check the value ofIsFalling
to see if the player is in the air.
If the player is in the air, they are not on the ground, so we can use thenot
node to invert the value of the bool and then set our "On Ground" variable to the output of that node.
Use theEventBlueprintUpdateAnimation
event to call thisSet
function each frame.
Now we have a bool that is constantly updated to tell our State Machine if we are on the ground or not.
-
Next, we can use that On Ground bool to trigger a transition from our Movement state to our Jump state.
In the State Machine, open the transition from Movement to Jump. We need to plug a boolean value into "Can Enter Transition", so by taking the value of "OnGround" and then using thenot
operator to flip it, we can cause this transition when we are not on the ground.
-
For the Movement state, we want to be able to blend between our Idle and Walk animations.
In the Content Drawer, create a new Blend Space 1D