Modular Game Features in UE5: plug ‘n play, the Unreal way

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Applause] hi my name is christoph pahlski in this video i'll show you some great new modular gameplay features that are coming in unreal engine 5. we will take a closer look at the game features system and see how it can help us maintain the project and make the development process more focused unreal engine 5 introduces modular gameplay features to the engine they will allow you to add new content in such a way so that the core game is completely agnostic to the new features coming in they make it possible to encapsulate bits of gameplay as a special kind of plugin and enable them or disable at will even during runtime they are also a huge win for games that run the game as a service model the system was primarily built for fortnite to handle seasonal content as well as one-time events like travis scott's concert using this approach the whole game doesn't have to go through certification again whenever you want to just add some new content this saves countless hours or even days of time and expense game features can be virtually anything new mechanics weapons skins ui elements or even new areas on the map the game should not be aware of implementation of our game feature and none of the feature's content should be referenced by any other part of the game or any other plugin it means that the game doesn't rely on the feature which allows you to turn your features on and off without breaking the game at any point game features are based on a new type of plugin to become a game feature a plugin should be placed in the plugins game features directory under your project root and contain a description file based on the game feature data struct the description file or the game feature data asset is the heart of a game feature it defines what game feature actions should be performed when the feature is activated and what primary asset types to register to the asset manager the engine comes with some actions predefined such as add cheats add components add data registry and edit data registry source the last two are useful for a data-driven gameplay creation approach you can read more about data registries in the ue5 documentation add cheats allows you to add an extension to the cheat manager enabling you to create feature related cheat commands that can be helpful in testing probably the most common at components allows you to add a specific component to all actors of a specified class that opted in to receive components from the component manager the source of the game features systems power lies in its ability to sort of inject new content and functionalities into the game in a non-invasive fashion when used correctly it can not only help keep the project tidy and maintainable but it could even be used for prototyping imagine being able to test any feature in such a way so that when you end up not liking it you can remove it from the game with just one click without consequences and if your prototype was just too messy you can keep the prototype and start preparing a clean version while still being able to get back to the prototype compare the features and then when you're done delete the prototype without any additional cleanup not to mention the ability to easily divide responsibilities among the team members and manage your features in general this approach requires a little bit of adaptation and careful planning of what should remain in the game and what should become a game feature let's take a look at an example i've created a simple game to show some of the capabilities of the system with all the game features deactivated my game consists of the main character interaction and damage systems collectibles base and a level with some boxes and an npc who clearly wants to talk to us the player can only move around dash defend and double jump on top of that i've created a few game features to showcase the system although in most cases your game features will exist in the game and be activated when the game is loaded sometimes depending on additional factors and policies like for example minimum game version required to activate the feature you can also activate and deactivate them during runtime for demonstration purposes i've set up a very simple quest system each game feature adds a quest component to the npc who is waiting on the map this way i can activate my features one by one by completing a series of simple quests in this video we'll take a look at how you could set up game features that can add components to actors for example add a hat on a player's head grant the player new abilities introduce a system or a resource spawn a new area on the map or add a new type of enemy with an ai the core game doesn't know a thing about how any of those are implemented that also means that the game doesn't rely on any of those features they can be freely activated and deactivated and the game will still work just fine thanks to that you could easily set up a new weapon a new enemy type or quickly prototype a new feature and experiment at will without worrying about breaking the game the features on the other hand are more than welcome to use content code or blueprints from the base game in regular development some of the presented features would rather go to the core game or be bashed together into one although when separated there are great examples to showcase specific capabilities of the system as isolated cases let's go through the steps to create a new game feature to use the game features system we have to enable two plugins first the game features plugin itself and the modular gameplay which will allow us to use the component manager a subsystem that helps manage adding new components to all actors of selected class who were registered to the system upon editor restart we will get an error telling us that the game feature data has to be registered as a primary asset type to the asset manager don't worry if you're not familiar with the asset manager the message also contains a useful link clicking which will fix the problem for you the next step is to create a new plugin once we've enabled the game features plugin we can now see a game feature as one of the templates it's content only but it can contain code as well you just have to add your modules manually you can see the game feature template already forces us to use the correct path under the plugins directory the game feature data asset named after the plugin should pop up it's located under your plugins root directory this asset defines your features behavior it's a place where you can add your actions or define primary asset types for the asset manager here we can also decide in which state we want our feature the state can be changed with those buttons also while play-in editor is active this takes effect immediately and persists across the whole editor session you can also change the initial state in the u plugin file which can be accessed by pressing the edit plugin button as you can see there is a message that tells us to deactivate the plugin first before editing the game feature data asset anything but active will do i usually put it in the registered state to ensure nothing is loaded in the memory when it's not needed have in mind that when the feature is in the installed state it won't be listed in the editor's content browser i want this plugin to make my spheres move up and down to achieve that i'll create a new actor component that my game feature will later add to the spheres the component will copy its owner's xy position and will apply a sine function with an amplitude of 2 meters to the z axis every frame i'll get the value returned by a sine function with the time that passed from the beginning of the game as an input i'll search for the get owner node and drag the return value away to get the set actor location and get actor location notes with the owner set as a target i'll split the location pins on both nodes i'll keep the x and y values without altering them in any way finally i'll overwrite the z value with the output of the sign multiplied by a hundred we haven't yet added any actions to our game feature so let's see that the spheres are completely stationary at the moment first we need to register our spheres to the game framework component manager subsystem as a receiver i'll do it on beginplay but you can opt in and opt out at any point in time now let's open the game feature data file and let's add an add component action remember to deactivate the feature first i'll set the actor class to my test sphere and the component class to my oscillating movement component i'll leave everything as is and activate the feature let's see if it works just like that we've created a new feature at this point we're free to develop the feature further add some extra assets maybe a particle system or some audio or simply refine our component the first game feature i've created is just a hat that appears on the player's head upon activation the magic card is fairly simple it just contains the hot mesh the material the spawn particle effect and a hub component which is simply a skeletal mesh component that on beginplay launches the particle system and blends in the hot mesh over a short amount of time you can also notice the quest gold component being defined here this is a component created for our npc when the quest gold component is registered the npc knows that there is a new quest available in the magiccat game feature data file we've added a couple of add component actions we want to add a hat component to all the actors of the player character class and the magic hat quest goal to all the actors of the npc class both player character and npc opted in to receive components from the component manager activating the next game feature grants the player an ability we can now fire magic missiles by pressing the left mouse button this game feature contains a complete functionality all the necessary assets and scripts are contained inside the plugin because i didn't want to reference other features and i also knew i'd want to create more abilities in the foreseeable future i've created the base of the ability system in the core game so i could easily add new abilities as game features later in the development or as an update i could have used the gameplay ability system for this application the system fits just so well to the gameplay modularity as well as the game features plugin itself but i've decided to show another a bit simpler yet more limited approach here especially since the gameplay ability system is the whole other subject to cover if you're curious you can later see how it was set up in the valley of the ancient by downloading the demo and tinkering around for my game's proprietary ability system i created just one c plus plus class it was necessary because i wanted to profit from the goods delivered by the enhanced input plugin the enhanced input plugin is unreal's modular approach to input mapping the input actions become assets that you can create inside your plugins the other type of asset is also introduced input mapping context can be used to map actions to specific inputs and then can be added to the enhanced input subsystem at any time to make our feature able to respond to the player's input events the new input actions also introduce modifiers and triggers thanks to them you can influence the values returned by the input events on the asset level as well as react to different trigger states in your event graph i could have worked around this without writing code but i wanted a cleaner solution the enhanced input plugin is built to be used in blueprints those awesome action binding nodes though can be done in actor based classes only but not in components and because i wanted to add abilities as components i had to write this simple class it just meant to allow mapping to the enhanced input actions from within the ability component i also named the events in a more ability themed fashion so it would be easier for a designer to work with now i can derive from this class in blueprint implement it and register a newly created ability to an add component action of my game feature on top of that we introduce a new animation to the game i've done this by creating an anime montage and playing it in an upper body slot i created in my character's animation blueprint to find out more about anime montages and slots check out our documentation the next one adds a currency to the game a coin spawner component was registered to the boxes so when they are destroyed they yield a handful of coins the player was granted an ability to attract coins with a magnet and collect them in their coin pouch both the coin magnet and the coin pouch are components in addition to everything we've already covered the coins feature introduces a ui element that is placed in the player's hud upon feature activation in this case the coin pouch component is responsible for the creation of the widget as you can see you can still use the most of the engine features freely without having to define a new game feature action most of the functionalities can be easily hooked into the game by utilizing components or creating a system that operates on data the game features system covers all that by default the next game feature in my example is a bit more complex it brings in a support for items together with the inventory component to the game in my game an item can have an effect that can be evaluated once for example to increase the player's max speed or jumps or happen periodically for example for healing the item's game feature brings the asset manager into play the whole game now recognizes items as a primary asset type so whenever a new item description is created within the project the game gains awareness of its existence and can now list it without loading which gives us the ability to later create a shop where the items could be bought this way i don't have to explicitly tell the shop that i've added a new item to the game the asset manager does it for me the items are based on a c class but it's as simple as it can be it derives from the u primary data asset so it could be found by the asset manager and only describes the properties of an item that are later filled with the data in the editor because i wanted the item effect class to be also part of the description i defined it in c 2 to be able to access it from code this is a completely empty class that only has a few specifiers defined blue printable blueprint type edit inline new and height categories they allow me to fully use this class as base for my blueprints create a new instance rate in the details panel and hide all the non-parameter variables from the designer by simply putting them in the item effect internal category the rest is handled by the inventory component that is added to the player's pawn and the item effects that can occur in certain conditions since we already have items in place we can now spawn a shop it's a new area on the map in the shop level blueprint i'm running a level sequence on the begin play so that the area doesn't just pop up out of nowhere the shop asks the asset manager for available items and lists them together with their prices in the shop ui allowing the player to buy them and add to their inventory the shop level layer contains just the tower and the shopkeeper actor placed inside you can also see the smoke particles from my spawn level sequence that is launched in the shop level blueprint the way of adding the shop level to the game is an example of an ad level instances action that i stole from the valley of the ancient project new actions can be easily created by the developers to best serve the specific needs of their games the value of the ancient is a great reference it's a aaa quality sample that we made free and available to download for anyone from the epic games launcher it includes a few examples of custom game feature actions built specifically for this project's needs the game feature actions can interact with your core games systems to let them know there is new content they should take care of you could create an action that grants the player new ability registers input mappings for new input actions that are introduced with the feature or as in our case loads a level layer in the way that satisfies our needs technically you could do most of this just using the add component action and then scripting everything in blueprints but if you'd like an elegant solution or if you need to use something inaccessible from blueprints take a closer look at the game feature actions i encourage you to check how those from valley of the ancient and the ones that come with the engine are built so you'd get a better understanding of how to create your own the new action loads a level instance on top of a specific map if it's currently loaded in the game it's very useful because adding a level instance to your game is the easiest way to spawn new areas or single objects on your scene especially if you want the feature to influence just a single map or a set of specific maps with a similar layout please note that while this is a good example of how the system is built it's not an officially supported way of doing that a better solution is in the works and will be added to the engine at a later time if you'd like to spawn something without the need of loading a level instance you can do that in a lot of different ways the system is very flexible you can for example create a spawner component and have the game feature added to an actor that is already on the level and have the component select the spot on which to spawn the new actor the place can be selected randomly or could be calculated in a more controlled way so that it would always yield the desired result you could also create a new game feature action where you could define the spawning behavior to steal the ed level instances action i went to the valley of the ancient source folder located classes game feature action underscore world action base and game feature action underscore add level instances and copied both dot h and cpp files of each class to my project's gameplay module and recompiled the editor the world action base is a base for all the game feature actions added to the valley of the ancient and the ed level instances allows us to add the level to the game upon feature activation and remove it when we turn the feature off the new action allows me to load the level in a pretty much the same way i would add components or cheats before there is a caveat though the shop has to rely on the coins and items game features it has to have the ability to read and manipulate players coin stash and add items to the inventory the editor shouldn't let you reference a class or an asset from another game feature you can bypass it by adding those features as direct dependencies of the shop i did it by simply modifying the plugin settings of the you plugin file from now on i'm the one responsible for making sure the dependency plugins are loaded correctly the next feature is another ability now we can cast a teleport spell while in the air this one is very similar to the magic missile it contains the particle system materials meshes the teleport input action and mapping and sounds needed for the effect the whole script of the ability is contained in the teleport ability component that derives from the same base class as the magic missile and handles input and the whole rather complicated teleport behavior the last game feature adds enemies to the game the whole ai behavior was defined in the feature itself this shows very well that you're not limited to any specific system or feature of the engine the game features are just like regular plugins so they can include any kind of content thanks to the game feature actions you can bring your code and content into the game without having to register it anywhere in the core game beforehand and it's just as simple i've imported and created all the assets i needed for the enemies to work together with mesh animations animation blueprint and the whole behavior tree and ai controller i only needed a way to add this to the game initially i thought of creating some generic spawn points in my main game and placing them on the level but since i didn't plan on adding new enemies that could use those spawn points in the future i decided to create a new level and add it with the ed level instances action the enemy's level layer contains only the enemy pawns that are placed in the spawn location relative to the main level's geometry there are a few tips that can help you when using the system try to create your game features so they are self-contained if you feel like you have to reference something from another feature it may be a good idea to rethink your design and ask yourself a question shouldn't the thing i'm referencing be the part of the core game since i'm trying to access it in other game features or do i really have to access it directly maybe i could react to an event already existing in the core game instead or use another approach a good example is the relationship between the coins and the shop in my demo i could probably move the idea of a currency to the main game instead of creating it as a game feature i may need to use the coins in many other places later in the development and if my game strongly relies on the certain feature i believe it should be in the core game not added as a game feature i can use a regular plugin for instance it is a perfect place for a system like this i would then avoid the dependency since you can't reference the level instance you want to add as a game feature from the core game you have to figure out a way of showing both levels at the same time i got the best results by simply loading the layer present in the game feature and dragging the main map to the levels window and making sure the streaming method is set to blueprint so that it doesn't ever load on its own to be able to activate your game features via blueprints you first need to create a blueprint function library based c class and add code along the lines of those snippets to the header and the source files accordingly you can create custom game feature activation policies it allows you to verify that the game feature can be loaded according to the rules you set yourself this can be done based on multiple factors one i expect to be the most common would be a custom field in your game features config file that could define for example the minimum required version of the game that could support our game feature this is done by deriving from the u game features project policies class in c you have to then set your class in the project settings game features game feature manager class here you can also force disable your game features and set additional plugin metadata keys for the engine to look for in your your plugin file and pass to your game features project policies class i strongly recommend checking out the recording of the live stream on modular game features on the unreal engine youtube channel with new possibilities come some limitations like you know should find more generic ways to communicate between your game and your features or your features between themselves you should also determine what does and what doesn't work as a game feature it may be a bit of a puzzle at times but after implementing a few test features yourself you should be able to quickly figure out what approach you want to go with also the system is so simple and flexible that you can easily make it suit your needs even if they're very demanding or specific to your game there's plenty to learn about the system while it's not very complicated to get a grasp of it may require a bit of practice to get used to and properly design your game architecture to utilize it as well as be able to make correct decisions on when to use features and when to put the content in the main game thank you for watching i hope you enjoyed this overview and found some inspiration on how you will make the most of the system happy tinkering cheers you
Info
Channel: Unreal Engine
Views: 68,410
Rating: undefined out of 5
Keywords: Unreal Engine, Epic Games, UE4, Unreal, Game Engine, Game Dev, Game Development
Id: 3PBnqC7TxvM
Channel Id: undefined
Length: 25min 43sec (1543 seconds)
Published: Fri Sep 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.