Reader small image

You're reading from  Game Development Projects with Unreal Engine

Product typeBook
Published inNov 2020
Reading LevelBeginner
PublisherPackt
ISBN-139781800209220
Edition1st Edition
Languages
Tools
Right arrow
Authors (4):
Hammad Fozi
Hammad Fozi
author image
Hammad Fozi

Hammad Fozi comes from a gaming background and has been extensively working on Unreal Engine since 2017. He has been part of some very successful AAA projects such as Virtua FanCave (and Metaverse), Unnamed AAA Sci-Fi DJ Experience, Heroes and Generals, and Creed: Rise to Glory VR. Hammad has worked with teams who have had experience working at Ubisoft, Warner Bros. Games, 2K Games, and more! He has successfully helped teams consisting of 10–30 people to scale to 150+ in size over his very short yet impressive career. Hammad currently works as a senior C++ game developer and has extensive experience in working with VR and augmented reality, PC/PS5/Xbox/Android/iOS/macOS game development, and Web3/Metaverse/NFT systems (within Unreal Engine).
Read more about Hammad Fozi

Gonçalo Marques
Gonçalo Marques
author image
Gonçalo Marques

Gonçalo Marques has been an active gamer since the age of 6. He has been using Unreal Engine since 2016 and has done freelance and consulting work using the engine. Gonçalo also released a free and open source plugin called UI Navigation, which has garnered an extremely positive reception with over 100,000 downloads and is still receiving frequent updates and fixes. Thanks to the development of this plugin, he became an Epic MegaGrant recipient. He is now working at Funcom ZPX, a game studio in Lisbon that has contributed to games such as Conan Exiles, Mutant Year Zero, and Moons of Madness. Gonçalo is currently working on a new Funcom game in the Dune universe.
Read more about Gonçalo Marques

David Pereira
David Pereira
author image
David Pereira

David Pereira started making games in 1998 when he learned how to use Clickteam's The Games Factory. He graduated in computer science from FCT-UNL, where he learned about C++, OpenGL, and DirectX, which allowed him to create more complex games. After working in IT consulting for a few years, he joined Miniclip in Portugal where he worked on popular mobile games such as 8 Ball Pool, Gravity Guy 1 and Gravity Guy 2, Extreme Skater, iStunt2, Hambo, and many others. Since then, he has been the lead developer for MPC in the John Lewis Christmas VR Experience, worked on an earlier version of Mortal Shell, and did volunteer work teaching people with Asperger's how to make games with Unreal Engine 4. Today, he's working on his own game, a soon-to-be-announced first-person action RPG.
Read more about David Pereira

Devin Sherry
Devin Sherry
author image
Devin Sherry

Devin Sherry is originally from Levittown, NY, located on Long Island. He studied the topics of Game Development and Game Design at the University of Advancing Technology where he had earned his Bachelor of Arts in Game Design in 2012. During his time in college, Devin worked as a game and level designer with a group of students called Autonomous Games on a real-time strategy styled, third-person shooter called The Afflicted using Unreal Engine 3/UDK where it was presented at GDC in 2013 at the GDC Play Showcase. Today, Devin works as an independent game developer located in Tempe, Arizona, where he works on personal and contracted projects. His achievements include the title Radial Impact, which can be found in the Community Contributions section of the Learn Tab of Unreal Engine 4's Launcher, and his work on his YouTube Channel, Devin Level Design, where he educates viewers on game development within Unreal Engine 3, UDK, and Unreal Engine 4.
Read more about Devin Sherry

View More author details
Right arrow

15. Collectibles, Power-Ups, and Pickups

Overview

In this chapter, we will create collectible coins and potion power-ups for the player. Furthermore, we will design the UI for the collectible coins using the Unreal Motion Graphics UI Designer, or UMG as it is more commonly known. Lastly, we will create bricks that will have these collectibles hidden inside of them. By the end of this chapter, you will be able to implement collectibles and power-ups for a player character to find within a level environment.

Introduction

In the previous chapter, you created the player projectile and used Anim Notifies to spawn the player projectile during the Throw animation. The player projectile will serve as the player's main offensive gameplay mechanic to use against the enemies throughout the level. Due to the combination of default Anim Notifies provided by Unreal Engine 4 and your own custom Anim_ProjectileNotify class, the player projectile mechanic looks and feels great.

The last set of mechanics that we need to develop are the coin collectible and potion power-up. Let's briefly break down how collectibles and power-ups have influenced other games, and what they will accomplish for our SuperSideScroller game.

Coin Collectible

Collectibles give the player an incentive to explore the level thoroughly. In many games, such as Hollow Knight, collectibles also serve as a form of currency that can be used to purchase upgrades for your character and items. In other, more classic platformers...

URotatingMovementComponent

URotatingMovementComponent is one of a few movement components that exist within Unreal Engine 4. You are already familiar with CharacterMovementComponent and ProjectileMovementComponent from the SuperSideScroller game project alone, and RotatingMovementComponent is just that – another movement component. As a refresher, movement components allow different types of movements to occur on actors, or characters, that they belong to.

Note

CharacterMovementComponent, which allows you to control the movement parameters of your character such as their movement speed and jump height, was covered in Chapter 10, Creating a SuperSideScroller Game, when you created the SuperSideScroller player character. ProjectileMovementComponent, which allows you to add projectile-based movement functionality to actors such as speed and gravity, was covered in Chapter 14, Spawning the Player Projectile, when you developed the player projectile.

RotatingMovementComponent...

Logging Variables Using UE_LOG

In Chapter 11, Blend Spaces 1D, Key Bindings, and State Machines, we used and learned about the UE_LOG function in order to log when the player should throw the projectile. We then used the UE_LOG function in Chapter 13, Enemy Artificial Intelligence, to log when the player projectile hit an object. UE_LOG is a robust logging tool we can use to output important information from our C++ functions into the Output Log window inside the editor when playing our game. Up until this point, we have only logged FStrings to display general text in the Output Log window to know that our functions were being called. Now, it is time to learn how to log variables in order to debug how many coins the player has collected.

Note

There is another useful debug function available in C++ with Unreal Engine 4, known as AddOnScreenDebugMessage. You can learn more about this function here: https://docs.unrealengine.com/en-US/API/Runtime/Engine/Engine/UEngine/AddOnScreenDebugMessage...

UMG

UMG, or Unreal Motion Graphics UI Designer, is Unreal Engine 4's main tool for creating UI for things such as menus, in-game HUD elements such as health bars, and other user interfaces you may want to present to the player.

In the SuperSideScroller game, we will only be using the Text widget to construct our Coin Collection UI in Exercise 15.04, Creating the Coin Counter UI HUD Element. We'll learn more about the Text widget in the next section.

Text Widget

The Text widget is one of the simpler widgets that exists. This is because it only allows you to display text information to the user and customize the visuals of this text. Almost every single game uses text in one way or another to display information to its players. Overwatch, for example, uses a text-based UI to display crucial match data to its players. Without the use of text, it would be very difficult – maybe even impossible – to convey key pieces of statistical data to the player, such as total damage dealt, total time playing the game, and many others.

The Text widget appears in the Palette tab within UMG. When you add a Text widget to the Canvas panel, it will display the text Text Block by default. You can customize this text by adding your text to the Text parameter of the widget. Alternatively, you can use Function Binding to display more robust text that can reference internal or external variables. Function Binding should be used whenever...

Adding and Creating UMG User Widgets

Now that we have created the Coin Collection UI in UMG, it is time to learn how to add and remove the UI to and from the player screen. By adding the Coin Collection UI to the player screen, the UI becomes visible to the player and can be updated as the player collects coins.

In Blueprints, there is a function called Create Widget, as shown in the following screenshot. Without a class assigned, it will be labeled Construct None, but do not let this confuse you:

Figure 15.17: The Create widget as it is by default, without a class applied

This function requires the class of the User widget to be created and requires a Player Controller that will be referenced as the owning player of this UI. This function then returns the spawned user widget as its Return Value, where you can then add to the player's viewport using the Add to Viewport function. The Create Widget function only instantiates the widget object; it does...

Timers

Timers in Unreal Engine 4 allow you to perform actions after a delay or every X number of seconds. In the case of the SuperSideScroller potion power-up, a timer will be used to restore the player's movement and jump to their defaults after 8 seconds.

Note

In Blueprints, you can use a Delay node in addition to Timer Handles to achieve the same results. However, in C++, Timers are the best means to achieve delays and reoccurring logic.

Timers are managed by Timer Manager, or FTimerManager, which exists in the UWorld object. There are two main functions that you will be using from the FTimerManager class, called SetTimer() and ClearTimer():

void SetTimer
(
    FTimerHandle & InOutHandle,
    TFunction < void )> && Callback,
    float InRate,
    bool InbLoop,
    float InFirstDelay
)
void ClearTimer(FTimerHandle& InHandle)

You may have...

Summary

In this chapter, you put your knowledge to the test to create the remaining gameplay mechanics for the SuperSideScroller game project. Using a combination of C++ and Blueprints, you developed the potion power-up and coins for the player to collect in the level. Also, by using your knowledge from Chapter 14, Spawning the Player Projectile, you added unique audio and visual assets to these collectible items to add a nice layer of polish to the game.

You learned and took advantage of the UMG UI system within Unreal Engine 4 to create a simple, yet effective, UI feedback system to display the number of coins that the player has collected. By using the binding feature of the Text widget, you were able to keep the UI updated with the number of coins the player has currently collected. Lastly, you created a Brick class using the knowledge you learned from the SuperSideScroller project to hide coins for the player so that they can collect and find them.

The SuperSideScroller...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Game Development Projects with Unreal Engine
Published in: Nov 2020Publisher: PacktISBN-13: 9781800209220
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Authors (4)

author image
Hammad Fozi

Hammad Fozi comes from a gaming background and has been extensively working on Unreal Engine since 2017. He has been part of some very successful AAA projects such as Virtua FanCave (and Metaverse), Unnamed AAA Sci-Fi DJ Experience, Heroes and Generals, and Creed: Rise to Glory VR. Hammad has worked with teams who have had experience working at Ubisoft, Warner Bros. Games, 2K Games, and more! He has successfully helped teams consisting of 10–30 people to scale to 150+ in size over his very short yet impressive career. Hammad currently works as a senior C++ game developer and has extensive experience in working with VR and augmented reality, PC/PS5/Xbox/Android/iOS/macOS game development, and Web3/Metaverse/NFT systems (within Unreal Engine).
Read more about Hammad Fozi

author image
Gonçalo Marques

Gonçalo Marques has been an active gamer since the age of 6. He has been using Unreal Engine since 2016 and has done freelance and consulting work using the engine. Gonçalo also released a free and open source plugin called UI Navigation, which has garnered an extremely positive reception with over 100,000 downloads and is still receiving frequent updates and fixes. Thanks to the development of this plugin, he became an Epic MegaGrant recipient. He is now working at Funcom ZPX, a game studio in Lisbon that has contributed to games such as Conan Exiles, Mutant Year Zero, and Moons of Madness. Gonçalo is currently working on a new Funcom game in the Dune universe.
Read more about Gonçalo Marques

author image
David Pereira

David Pereira started making games in 1998 when he learned how to use Clickteam's The Games Factory. He graduated in computer science from FCT-UNL, where he learned about C++, OpenGL, and DirectX, which allowed him to create more complex games. After working in IT consulting for a few years, he joined Miniclip in Portugal where he worked on popular mobile games such as 8 Ball Pool, Gravity Guy 1 and Gravity Guy 2, Extreme Skater, iStunt2, Hambo, and many others. Since then, he has been the lead developer for MPC in the John Lewis Christmas VR Experience, worked on an earlier version of Mortal Shell, and did volunteer work teaching people with Asperger's how to make games with Unreal Engine 4. Today, he's working on his own game, a soon-to-be-announced first-person action RPG.
Read more about David Pereira

author image
Devin Sherry

Devin Sherry is originally from Levittown, NY, located on Long Island. He studied the topics of Game Development and Game Design at the University of Advancing Technology where he had earned his Bachelor of Arts in Game Design in 2012. During his time in college, Devin worked as a game and level designer with a group of students called Autonomous Games on a real-time strategy styled, third-person shooter called The Afflicted using Unreal Engine 3/UDK where it was presented at GDC in 2013 at the GDC Play Showcase. Today, Devin works as an independent game developer located in Tempe, Arizona, where he works on personal and contracted projects. His achievements include the title Radial Impact, which can be found in the Community Contributions section of the Learn Tab of Unreal Engine 4's Launcher, and his work on his YouTube Channel, Devin Level Design, where he educates viewers on game development within Unreal Engine 3, UDK, and Unreal Engine 4.
Read more about Devin Sherry