<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Denis Savosin on Medium]]></title>
        <description><![CDATA[Stories by Denis Savosin on Medium]]></description>
        <link>https://medium.com/@denismakesgames?source=rss-a7b26c94abfb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Denis Savosin on Medium</title>
            <link>https://medium.com/@denismakesgames?source=rss-a7b26c94abfb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:12:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@denismakesgames/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[First Look at Unreal Engine 5 Game Features Plugin]]></title>
            <link>https://denismakesgames.medium.com/first-look-at-unreal-engine-5-game-features-plugin-35fdc1e14f01?source=rss-a7b26c94abfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/35fdc1e14f01</guid>
            <category><![CDATA[videogames]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[gaming]]></category>
            <category><![CDATA[game-design]]></category>
            <category><![CDATA[creator-voice]]></category>
            <dc:creator><![CDATA[Denis Savosin]]></dc:creator>
            <pubDate>Sat, 29 May 2021 17:35:28 GMT</pubDate>
            <atom:updated>2021-06-01T00:55:25.942Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xG0-1Ue8nAKWQnVAmGyKoA.png" /></figure><h4>CREATOR VOICE</h4><h4>Examining why the new Game Features grabbed my attention</h4><p><strong>Hello! My name is Denis Savosin. I work as a Technical Designer at Yager, an independent developer of computer and video games based in Berlin, Germany. Unreal Engine 5 Early Access is out now and is full of new world-building and rendering features.</strong> While the <a href="https://docs.unrealengine.com/5.0/en-US/RenderingFeatures/Nanite/">Nanite</a>, <a href="https://docs.unrealengine.com/5.0/en-US/RenderingFeatures/Lumen/">Lumen</a>, and <a href="https://docs.unrealengine.com/5.0/en-US/WorldFeatures/WorldPartition/">World Partition</a> features which some of us are exploring right now are awesome, the <a href="https://docs.unrealengine.com/5.0/en-US/GameplayFeatures/GameFeaturesAndModularGameplay/">Game Features and Modular Gameplay</a> stood out to me. They allow game developers to combine the power of the Gameplay Ability system with the robust input mapping.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3QE_EFryNRPLd30k89oV7w.jpeg" /><figcaption>Screen from the new Valley of the Ancients gameplay demo for UE5. Source: YouTube.</figcaption></figure><p>In addition, you now have the ability to manage world systems, actor components, and manage resources using Data Registers. It unlocks new possibilities for developers to build complex, multi-mode games without having to worry about referencing content, gameplay logic, and blueprint actors “just in case” they are needed for a specific scenario.</p><p>I’ve spent some time exploring the <em>Valley Of The Ancients</em> project and the basics of this plugin. After a few hours, I’ve created a simple example of adding a new Gameplay Ability to the Game Feature plugin. Let’s start and add the ability to fly with Hover Drone to the “<em>Battle with the Ancien</em>t” level.</p><h3>Project setup</h3><p>You probably already have the demo project ready and waiting in the Epic Games Launcher. Some people can encounter errors for missing hostfxr.dll when starting up the project. This can be fixed by installing a required version of the <a href="https://download.visualstudio.microsoft.com/download/pr/e2c406c9-d40d-442c-b6cd-bc60a84d159f/556f8d45b3f5fa932785e138468a6ee3/dotnet-sdk-3.1.115-win-x64.exe">.NET SDK</a>. The link is kindly provided by an awesome <a href="https://unrealslackers.org/">Discord</a> community.</p><p>After launching a project and generating VS project file (Tools→Generate VS Project File) we have a project Content folder and C++ classes folders. Now pay attention to the Hover Drone Content and Ancient Battle Content folders. From my understanding, those were put outside the main Content folder by Epic on purpose. They are plugin folders and store Game Features specific content separately from the main content. There are data validators to check that feature plugins can reference content only from the main Content folder. I had to disable that check, to reference content from different folders in Feature assets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B4YzfdcYiL-0QHB3" /></figure><p>Disable AssetReferencingPolicy validation in DefaultGame.ini to allow referencing assets from other folders than the project Content folder:</p><p>bEnableAssetFiltering_TEMP=False<br>bEnableAssetValidator_TEMP=False</p><pre>[/Script/AssetReferenceRestrictions.AssetReferencingPolicySettings]<br>EnginePlugins=(DefaultRule=(CanReferenceTheseDomains=(&quot;ProjectContent&quot;),bCanProjectAccessThesePlugins=True,bCanBeSeenByOtherDomainsWithoutDependency=True),AdditionalRules=)<br>ProjectPlugins=(DefaultRule=(CanReferenceTheseDomains=(&quot;ProjectContent&quot;),bCanProjectAccessThesePlugins=True,bCanBeSeenByOtherDomainsWithoutDependency=True),AdditionalRules=)<br>DefaultProjectContentRule=(CanReferenceTheseDomains=(&quot;HoverDrone&quot;,&quot;AncientBattle&quot;,&quot;&quot;))<br>bEnableAssetFiltering_TEMP=False<br>bEnableAssetValidator_TEMP=False</pre><h3>Game Features overview</h3><p>So, the project has two Feature Plugins: Hover Drone and Ancient Battle.</p><p>Hover Drone has the content specific for launching the Hover Drone at a campfire and flying around the map, as was presented during the showcase. That content includes:</p><ol><li>Animations and anim montages are loaded with a plugin and used with gameplay ability.</li><li>Audio folder with activate/deactivate effects</li><li>GA_DeployHoverDrone Ability, Drone Camera blueprints</li><li>New Input Mapping Context and Input Action assets to map player’s startup abilities and hover steering inputs when we start the map at the campfire.</li></ol><p>On the other hand, the Ancient Battle content folder contains everything needed for loading a Dark World level, adding new Light Dart and Dodge abilities, sequencer blueprints to orchestrate the battle with the Ancient, and so on.</p><p>When we launch the game in the campfire, thanks to the Gameplay Features, the content of the Hover Drone folder is being loaded, the ability is being granted to the Echo and an appropriate input mapping is selected. When we leave the Dark World area, the content of the Ancient Battle folder is being offloaded, and we lose granted Light Dart and Dodge abilities, as well as battle level data layer and actors spawned. It is amazing, isn’t it?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kV88nHQ_VEXJ1L_A" /></figure><p>When we Interact with the Dark World Rift, the game unloads:</p><ul><li>Deploy Hover Drone gameplay ability removed from BP_EchoCharacter active abilities list</li><li>Hover Drone Ability Input Mapping</li><li>Drone-specific BPs like AutoOff and Campfire Transition Camera.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5a6ct9Dc9y7SKTLA" /></figure><p>When the Ancient Battle level is loaded, the Toggle Game Features Plugin function-call loads AncientBattle Data-Asset with the following content:</p><ul><li>Light Dart and Dodge gameplay abilities</li><li>New input mapping asset. For example, it changes left mouse button mapping from unloaded Hover Drone ability to new Light Dart ability.</li><li>Animation Blueprint Layer for Echo, containing Levitation state for casting Light Dart.</li><li>Other assets and sequencer files, that are used for the battle scene.</li><li>World Targetable Manager — a world system used for selecting objects we can shoot with Light Dart.</li></ul><p>That final point is a very good example of how the Features Plugin allows developers to add entirely new features based on the context, rather than creating and maintaining a global subsystem and calling it where necessary. Goodbye, Singletons!</p><p>When we interact with the Dark World Rift, it calls Ancient Game Mode to start the transition from a camp to Dark World, offloading Features used on the starter map and loading features used for battling the Ancient. To do that, the Ancient Game Mode class has a C++ function callable from blueprints, where we can pass the name of our desired feature DataAsset and select to enable or unload the given feature plugin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/0*BqNqjRYG-h1eulGU" /><figcaption>ValleyoftheAncient/Content/AncientContent/Blueprints/Framework/BP_AncientGameMode.uasset</figcaption></figure><p>Function definition inside Ancient Game Mode Base class:</p><pre>void AAncientGameModeBase::ToggleGameFeaturePlugin(FString GameFeaturePluginName, bool bEnable)<br>{<br>	FString PluginURL;<br>	<br>	UGameFeaturesSubsystem::Get().GetPluginURLForBuiltInPluginByName(GameFeaturePluginName, PluginURL);</pre><pre>	bEnable ? UGameFeaturesSubsystem::Get().LoadAndActivateGameFeaturePlugin(PluginURL, FGameFeaturePluginLoadComplete()) : UGameFeaturesSubsystem::Get().UnloadGameFeaturePlugin(PluginURL);<br>}</pre><p>For Editor there are console commands provided to reset the feature plugins to their default state when launching from the Ancient map (started camp).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/0*Zo3Mhq_tP9OyLbq8" /></figure><p>The reason is that Feature Plugins are persistent and all applied modifications will stay intact when we re-launch the PIE session.</p><h3>Adding a new ability to the Ancient Battle feature</h3><p>Adding and removing content through Game Features is managed in Editor using GameFeatureData assets, which contains the list of <strong>Actions</strong> to perform when the plugin is being loaded. The list of actions available in the demo project are as follows:</p><ol><li><strong>Add World System</strong> — adds subclasses of UGameFeatureWorldSystem to world subsystems manager.</li><li><strong>Add Spawned Actors</strong> — adds general-purpose Actors, like triggers, cameras, other level-specific actors, and utilities.</li><li><strong>Add Level Instances</strong> — level-streaming, loads selected Level to the Target World. In this case, it streams Ancient Battle Gameplay sub-level to the main Ancient World map.</li><li><strong>Add Input Context Mapping</strong> — adds Input Mapping Context asset, overloading or overwriting the previous input scheme.</li><li><strong>Add Abilities</strong> — adds new gameplay abilities to the actors through UGameFrameworkComponentManager. Actors should be of type AModularCharacter.</li></ol><p>Developers can create their own Actions to support their own Game Features, by writing extensions to base UGameFeatureAction class and overriding its virtual function members.</p><pre>/** Represents an action to be taken when a game feature is activated */<br>UCLASS(DefaultToInstanced, EditInlineNew, Abstract)<br>class GAMEFEATURES_API UGameFeatureAction : public UObject<br>{<br>	GENERATED_BODY()</pre><pre>public:<br>	virtual void OnGameFeatureRegistering() {}</pre><pre>	virtual void OnGameFeatureActivating() {}</pre><pre>	virtual void OnGameFeatureLoading() {}</pre><pre>	virtual void OnGameFeatureDeactivating(FGameFeatureDeactivatingContext&amp; Context) {}</pre><pre>#if WITH_EDITORONLY_DATA<br>	virtual void AddAdditionalAssetBundleData(FAssetBundleData&amp; AssetBundleData) {}<br>#endif<br>};</pre><p>With the theory out of the way, let’s add the ability to fly with the Hover Drone inside the Ancient Battle level. To do this, we need to open Ancient Battle Data-Asset (<em>ValleyoftheAncient/Plugins/GameFeatures/AncientBattle/Content/AncientBattle.uasset</em>) and add GA_DeployHoverDrone ability to the Actions→Abilities list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/0*rpSaaVqmiIqG41iK" /></figure><p><strong>IMPORTANT!</strong> Make sure you’ve disabled asset reference validation checks in DefaultGame.ini as mentioned in the project setup paragraph. Otherwise, the HoverDrone content will not be available for use in the Ancient Battle plugin and vice-versa.</p><p>Then add the DeployDrone Input Action to the Light Dart Input Mappings and assign the ‘E’ keyboard button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/0*1hhXrxJb_ksS0xGK" /></figure><p>Save assets and launch the game.</p><h3>Result</h3><p>Now the Hover Drone ability is available to use in the Dark World level alongside the Light Dart throw. You can take it from here and play around with the Game Features plugin, creating new or changing provided features, for example, to enable throwing Light Dart inside the campfire or adding new actors to the level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8vGxdO2OeKV1qghUgBDnYw.gif" /></figure><h3>The exciting future of modular gameplay systems</h3><h4>Managing multi-mode games</h4><p>Say, for example, you’re working on a multiplayer project with lots of abilities and actor components necessary for the role-based combat gameplay. But you also have a Tutorial level to teach players basic game mechanics, or you have a pre-match lobby level to hang around with other players where most of the game subsystems, actor components, and abilities are not needed. Now there is a simple solution to disable this content and add or remove features based on the needs for the specific game mode.</p><h4>Quest systems and other world-specific subsystems</h4><p>When I was working on quest systems for one of the AAA action games, I encountered the issue of managing actor references, utility blueprints, and streaming levels. They all needed to be loaded into the memory once the player had activated the first step of the quest chain. I see developers going creative with the Game Features and building well-designed, robust “modules” for the complex systems, loading one at a time when needed.</p><h4>Extensions for live games</h4><p>Adding new character abilities or a vendor on the map for the seasonal Christmas event would be less of a headache, as those temporal features can be rolled out without affecting the core game content and feature set. That also enables technical design and content teams to spend more time prototyping and testing hypotheses without adding extra burden on the engineering side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*hI1PggEycGg95WGfN5OzxQ.png" /></figure><p>I hope you found this First-Look at the Game Features plugin useful. I am excited and looking forward to seeing how this feature set will be developed by Epic over time and how development teams will adopt it in their projects. If you liked this material, please recommend it to your UE friends and follow <a href="http://denismakes.games/">denismakes.games</a> for more Unreal Engine and game design content. You can follow me on <a href="https://twitter.com/denismakesgames">Twitter</a> and find me on <a href="https://www.linkedin.com/in/denis-savosin-it/">LinkedIn</a> as well!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35fdc1e14f01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Launching Grenades in Unreal Part 2: Attributes, Gameplay Effects, Replication]]></title>
            <link>https://denismakesgames.medium.com/launching-grenades-in-unreal-part-2-attributes-gameplay-effects-replication-37e63d798f60?source=rss-a7b26c94abfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/37e63d798f60</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[gaming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[game-design]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Denis Savosin]]></dc:creator>
            <pubDate>Sat, 27 Feb 2021 18:03:33 GMT</pubDate>
            <atom:updated>2021-05-05T14:15:30.348Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xG0-1Ue8nAKWQnVAmGyKoA.png" /></figure><h4>GAME DEV MASTERCLASS</h4><h4>Another grenade-popping GAS tutorial</h4><p><strong>A SimpleGAS is a set of tutorials for entry-level Unreal Engine enthusiasts who wants to leverage the power of the Gameplay Ability System in their prototypes.</strong> While there are great tutorials and GitHub repositories which cover the topic of GAS in more depth, this tutorial is requiring a minimum C++ setup and showcases working examples built entirely using Blueprints. This tutorial is for those who are new to Unreal Engine gameplay/multiplayer development or simply need an easy headstart before diving into more sophisticated GAS-related content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*RPI0zW3ngJDOt7mrVLIw6A.gif" /></figure><h3>Intro</h3><p>Welcome back! In <a href="https://denismakesgames.medium.com/launching-grenades-in-unreal-with-gameplay-ability-system-part-1-3179f38f3730">Part 1</a> of the tutorial series, we covered a basic ability set up to launch a grenade projectile using the minimum code required to work with Gameplay Abilities. Today we are going to add a player character attribute set, deal damage using gameplay effects, and touch a topic of replication system in Unreal Engine.</p><blockquote><em>Want to read this story later? </em><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_read_later_text"><em>Save it in Journal.</em></a></blockquote><p>In the end, you will find the link to the <a href="https://github.com/dsavosin/SimpleGAS">Simple GAS repository</a>, as well as other useful resources to follow after completing this tutorial.</p><h3>Attribute Set</h3><p>Think of attribute sets as of… well classic character attributes in your favorite RPG game. Health, Mana, Stamina, Damage, Resistance, etc. If Abilities are the bones of the Gameplay Ability System, then the Attributes are its blood. In GAS they act not just as a replicated property storage for your characters and systems but also can control states of your game without writing complicated logic to handle dozens of edge cases.</p><p>To create a basic attribute set for our player character, create a new class inherited from <strong>UAttributeSet</strong> and add the following declarations to the header file:</p><pre>#pragma once</pre><pre>#include &quot;CoreMinimal.h&quot;<br>#include &quot;AttributeSet.h&quot;<br>#include &quot;AbilitySystemComponent.h&quot;<br>#include &quot;CharacterBaseAttributeSet.generated.h&quot;</pre><pre>// Macros from AttibuteSet.h to generate boilerplate code for getters and setters.<br>#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \\<br>	GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \\<br>	GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \\<br>	GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \\<br>	GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)</pre><pre>/**<br> * <br> */<br>UCLASS()<br>class SIMPLEGAS_API UCharacterBaseAttributeSet : public UAttributeSet<br>{<br>	GENERATED_BODY()</pre><pre>public:</pre><pre>	UCharacterBaseAttributeSet();</pre><pre>	UPROPERTY(BlueprintReadOnly, Category = &quot;Health&quot;, ReplicatedUsing = OnRep_Health)<br>	FGameplayAttributeData Health;<br>	ATTRIBUTE_ACCESSORS(UCharacterBaseAttributeSet, Health)</pre><pre>	virtual void GetLifetimeReplicatedProps(TArray&lt;FLifetimeProperty&gt;&amp; OutLifetimeProps) const override;</pre><pre>protected:</pre><pre>	UFUNCTION()<br>	virtual void OnRep_Health(const FGameplayAttributeData&amp; OldHealth);<br>};</pre><p>Create an implementation of the constructor in the .cpp file and initialize Health value to 100.</p><pre>UCharacterBaseAttributeSet::UCharacterBaseAttributeSet() :<br>	Health(100.0f)<br>{<br>}</pre><p>Because we specified our attribute as being replicated using the ReplicatedUsing = OnRep_Health keyword in UPROPERTY parameters, we need to declare and implement the OnRep_Health function.</p><pre>void UCharacterBaseAttributeSet::OnRep_Health(const FGameplayAttributeData&amp; OldHealth)<br>{<br>	GAMEPLAYATTRIBUTE_REPNOTIFY(UCharacterBaseAttributeSet, Health, OldHealth);<br>}</pre><p>And because our attributes are natively replicated properties, our UCharacterBaseAttributeSet class must override a <a href="https://docs.unrealengine.com/en-US/API/Runtime/Engine/GameFramework/AActor/GetLifetimeReplicatedProps/index.html">GetLifetimeReplicatedProps</a> function.</p><p>If you want to expand an attribute set with more attributes, for each attribute you need to add a new DOREPLIFETIME_CONDITION_NOTIFY line with a new attribute as a parameter.</p><pre>void UCharacterBaseAttributeSet::GetLifetimeReplicatedProps(TArray&lt;FLifetimeProperty&gt;&amp; OutLifetimeProps) const<br>{<br>	Super::GetLifetimeReplicatedProps(OutLifetimeProps);</pre><pre>	DOREPLIFETIME_CONDITION_NOTIFY(UCharacterBaseAttributeSet, Health, COND_None, REPNOTIFY_Always);<br>}</pre><h3>ASimpleGasCharacter class</h3><p>Add the following header file to the character class header.</p><pre>#include &lt;Runtime/Engine/Public/Net/UnrealNetwork.h&gt;</pre><p>Declare our BaseAttributeSet property. Adding the ‘class’ keyword makes the variable an inline forward declared and requires no UCharacterBaseAttributeSet header file in our ASimpleGasChatacter header, as we do not access class-specific functionality.</p><pre>/** Base Set Of Attributes */<br>	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Abilities, meta = (AllowPrivateAccess = &quot;true&quot;))<br>	class UCharacterBaseAttributeSet* BaseAttributeSet;</pre><p>Declare OnHealthAttributeChanged function, which we later will add to a GAS-specific attribute change delegate. Gameplay Ability Tasks rely on this function to provide a functioning tracking of attribute changes. Add a dummy implementation to the .cpp file.</p><pre>protected:</pre><pre><strong>	virtual void OnHealthAttributeChanged(const FOnAttributeChangeData&amp; Data);</strong></pre><pre>	void BeginPlay() override;</pre><pre>void ASimpleGASCharacter::OnHealthAttributeChanged(const FOnAttributeChangeData&amp; Data)<br>{<br>	float Health = Data.NewValue;<br>	UE_LOG(LogTemp, Warning, TEXT(&quot;Health: %f&quot;), Health);<br>}</pre><p>As you should have to get used to the process already, create the default subobject of our attribute set class inside the ASimpleGASCharacter class constructor.</p><pre>// Create a follow camera<br>	FollowCamera = CreateDefaultSubobject&lt;UCameraComponent&gt;(TEXT(&quot;FollowCamera&quot;));<br>	FollowCamera-&gt;SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation<br>	FollowCamera-&gt;bUsePawnControlRotation = false; // Camera does not rotate relative to arm</pre><pre>	AbilitySystemComponent = CreateDefaultSubobject&lt;UAbilitySystemComponent&gt;(TEXT(&quot;AbilitySystemComponent&quot;));</pre><pre>	BaseAttributeSet = CreateDefaultSubobject&lt;UCharacterBaseAttributeSet&gt;(TEXT(&quot;AttributeSet&quot;));</pre><p>Our player character will have multiple startup abilities, which are not bound to the specific input. That’s why we have to change a startup ability variable declaration to the TArray container and grant those abilities upon startup. Change your existing code in the BeginPlay function to:</p><pre>void ASimpleGASCharacter::BeginPlay()<br>{<br>	Super::BeginPlay();</pre><pre>	if (AbilitySystemComponent)<br>	{<br>		FGameplayAbilityActorInfo* actorInfo = new FGameplayAbilityActorInfo();<br>		actorInfo-&gt;InitFromActor(this, this, AbilitySystemComponent);<br>		AbilitySystemComponent-&gt;AbilityActorInfo = TSharedPtr&lt;FGameplayAbilityActorInfo&gt;(actorInfo);</pre><pre>		for(const auto&amp; StartupAbility : StartupAbilities)<br>		{<br>			if (StartupAbility &amp;&amp; HasAuthority())<br>			{<br>				AbilitySystemComponent-&gt;GiveAbility(FGameplayAbilitySpec(StartupAbility.GetDefaultObject(), 1, 0));<br>				AbilitySystemComponent-&gt;InitAbilityActorInfo(this, this);<br>			}<br>		}</pre><pre>		AbilitySystemComponent-&gt;GetGameplayAttributeValueChangeDelegate(BaseAttributeSet-&gt;GetHealthAttribute()).AddUObject(this, &amp;ASimpleGASCharacter::OnHealthAttributeChanged);<br>	}<br>}</pre><p>At the bottom, we also bound our OnHealthAttributeChanged function to <strong>GetGameplayAttributeValueChangeDelegate</strong> delegate, which now will listen to the changes in our Health attribute.</p><h3>Death Ability</h3><p>In the beginning, I’ve mentioned how the attributes are the blood of the system and how the attribute changes can change the state of the game with as much as one Blueprint node. A Death ability is a perfect candidate to showcase this. Create a GA_DeathAbility blueprint and implement the following logic in its blueprint graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gbeoe4nPuNyOT0HeGWoUbA.png" /></figure><p>The essential function of the Death ability is to listen to the changes in our Health attribute and do something (e.g change a state of our character) once the attribute meets a certain condition.</p><p>That what is the Wait for Attribute Change with Comparison task is doing, then the known from the last tutorial PlayMontageAndWait tasks playbacks a selected montage (in this case its the same montage used at the start of the match, but you can modify it with one of your choices) and Ends ability afterward. When ability ends, we get an owning actor, cast to ThirdPersonCharacter, and call EventDie and Reset event declared in the character blueprint.</p><p>This ability is given to a player character on the startup and activated in its OnPossesed blueprint event using its Ability Tag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*OvNLUPK-p2RexiNKH8QZyw.png" /></figure><p>EventDieAndReset event declared in the character blueprint calls ApplyGameplayEffectToSelf function which uses gameplay effect GE_RestoreHealth to restore character health attribute to its default maximum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*WGJM8gprHRH4_Vr2NHLrMw.png" /></figure><p>Finally, we reached the most interesting part of this tutorial and the most powerful trick on the sleeve of GAS.</p><h3>Gameplay Effects</h3><p>Open a GE_RestoreHealth class or create your own by selecting GameplayEffect base class in the new Blueprint class creation wizard. Pro-tip: when a new GE blueprint is created, It will open up with the Full Graph Editor. Reopen it to see only the Class Defaults window, as GEs are data-only blueprints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U7uOxhqQ1HqqxxeXcSMKTg.png" /><figcaption>GE_RestoreHealth class defaults</figcaption></figure><p>Let’s review the basic settings of the GameplayEffect class. Today we just focus on the basics which will allow you to create basic gameplay effects and modify attributes and control the logic of your prototypes, before diving into more depths.</p><ul><li>Duration Policy — how long this GE should last, or should it be Instant like in our case. Imagine having a DoT in your MMORPG game or a cooldown on your special spell — select a Has Duration policy and specify a duration of the effect. In case of something like damage from bullets, grenades, or utility effects to alter character attributes, choose an Instant policy.</li><li>Modifiers — modifies target attributes. You can select any attribute you want to modify on the target of your GE, then choose how you would like to modify it. In our case we want to set health to maximum from any amount present, so select the Override option.</li><li>Magnitude Calculation Type — how an attribute change will be calculated. Here we will select Scalable Float where we can put a float parameter or select an appropriate data table.</li></ul><h3>Grenade class</h3><p>Now we understand how the gameplay effect class is working, we can create a GE_GrenadeInstantDamage class and use this damaging effect to all actors of class Third Person Character overlapped by the exploding grenade.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A-DBAfO3h90BmG8C6swDUw.png" /></figure><p>Here are simple GE settings to use, if you want instantly subtract 50 HP points from the target Health attribute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m79aey7g7JLRBE7TERE5sw.png" /><figcaption>GE_GrenadeInstantDamage</figcaption></figure><h3>Is it possible to pass attribute changes to a GE from the grenade object? Yes!</h3><p>What if instead of reading a float attribute from the gameplay effect class setup or using a separate table to store those values, you want to pass a modifier from a caller class. For example, there is a calculation you need to perform inside your actor class, instead of using hardcoded values or tables. Another good case is simply passing the data between otherwise unrelated/unreferenced actors using the gameplay effect. But in that case, we are limited only to our attribute values, of course. There are two options: using a dedicated calculation class. or setting magnitude “by caller”.</p><p>For this, we need to create a Data Tag — an identifier, which then we use to forward the magnitude set by the caller to the right attribute. Go ahead and add ‘DataTag.Health’ and assign it in the Set by Caller selected calculation type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*0_V6pqlrKN35vbIgYqwYng.gif" /></figure><p>Now if you open a BP_Projectile in the SimpleGAS project, you will see this option to apply damage by creating a GameplayEffectSpec first, and then set how much health we want to subtract by providing a Magnitude length and the Data. Tag linked to the Health attribute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mwQ8IA57sLt14sVHGZg1xw.png" /></figure><p>You can use either ApplyGameplayEffectTo_ or ApplyGameplayEffectSpec for your needs depending on the type of the gameplay effect and the way you’re willing to modify attributes.</p><h3>Networking 101</h3><p>Let’s touch on the basics of Networking in Unreal Engine. Each Actor can be replicated from Server to Clients if we select the Replicates option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*GtPLTlvbX62eE4v6OuRkgQ.png" /></figure><p>On actor event Begin Play we want to set the projectile we can use a Switch Has Authority macro which has two execution pins: one for Server (Authority) and one for Client (Remote). When a new projectile is created, it will be created on both server and client. Using this macro we can disable the visibility of a projectile on the Server (so our owning player will see the local version of the projectile) and set a timer to execute an Explode event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hJ87jilk9aRkh666-2QHWA.png" /></figure><p>EventExplode_Multicast is the event that will be executed on a server and all owning clients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*vyW4--iVrAtcezJR2lfijg.png" /></figure><p>On the Server, we are going through all actors overlapped by the sphere collision component and apply a damaging effect through ApplyGameplayEffectTo_ or ApplyGameplayEffectSpec to each actor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XwLvRCTPt8OEKsHFUHAUTw.png" /></figure><p>On Remote client, we Spawn explosion emitter, play sounds and hide the projectile before it’s being recycled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D0j6Txcwg7ikleJGxQv77Q.png" /></figure><p>An overview of the explosion and damage dealing logic in BP_Projectile. A rule of thumb is that damage-dealing logic should be executed on Authority, as a Server should make a final call in what numbers are applied to the damaged actors and replicate those changes through GAS. At the same time an explosion effect, sounds, and other visual feedback don’t need to be created or invoked on the server and can be executed on clients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HdnsXmGiwc98ZHiHE1U1Fg.png" /></figure><p>To test that everything works correctly, open the Play In Editor options and choose the Net Mode: Play as Client. That will simulate launching the game as a client which connects to the remote server. Select the number of players to launch. That will open two windows to simulate 2 players connected to a server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*xdR_Xf0EeqyPX16U_ntwQQ.gif" /></figure><h3>Conclusion</h3><p>Here is the final result! I hope after reading both this and Part 1 you will be familiar with the basics of the Gameplay Ability System and can experiment with it in your projects, using the minimum required C++ setup and handling the Gameplay Effects, such as Damage, Healing, and DoTs in blueprints. We just scratched the tip of the iceberg in GAS and if you’d like to see more tutorials on GAS, networking, or another topic, please follow me on the social platforms and leave comments on what you’d like to see next. Until next time!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*RPI0zW3ngJDOt7mrVLIw6A.gif" /></figure><h3>Useful Links</h3><p><a href="https://denismakesgames.medium.com/launching-grenades-in-unreal-with-gameplay-ability-system-part-1-3179f38f3730">Part 1 on Medium</a></p><p><a href="https://denismakes.games/2020/10/17/launching-grenades-in-unreal-with-gameplay-ability-system-part-1/">Part 1 on denismakesgames.com</a></p><p>SimpleGAS GitHub: <a href="https://github.com/dsavosin/SimpleGAS">https://github.com/dsavosin/SimpleGAS</a></p><p>Famous GAS Documentation by Tranek: <a href="https://github.com/tranek/GASDocumentation">https://github.com/tranek/GASDocumentation</a></p><p>📝 Save this story in <a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_read_later_text">Journal</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37e63d798f60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Launching Grenades in Unreal with Gameplay Ability System: Part 1]]></title>
            <link>https://denismakesgames.medium.com/launching-grenades-in-unreal-with-gameplay-ability-system-part-1-3179f38f3730?source=rss-a7b26c94abfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/3179f38f3730</guid>
            <category><![CDATA[unreal-engine]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unreal-engine-4]]></category>
            <category><![CDATA[prototyping]]></category>
            <dc:creator><![CDATA[Denis Savosin]]></dc:creator>
            <pubDate>Wed, 18 Nov 2020 12:43:27 GMT</pubDate>
            <atom:updated>2021-05-01T06:17:03.680Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xG0-1Ue8nAKWQnVAmGyKoA.png" /></figure><h4>GAME DEV MASTERCLASS</h4><h4>An easily-digestible GAS tutorial</h4><p><strong>This is the first tutorial in the series dedicated to Gameplay Ability System.</strong> The goal for these tutorials is to be easily digestible, 10 minute-long reads focused on getting a working prototype of a gameplay mechanic on screen as fast as possible. So whether you’re new to Unreal Engine or new to Gameplay Ability System, Designer, Animator, or Technical Artist, these tutorials will help you build your projects faster and stop being afraid of using GAS for your projects.</p><p>This series requires little to no knowledge of C++. It requires a basic knowledge of Blueprints scripting and general knowledge about unreal asset types and their use for building gameplay. I tried to cover steps in as much detail as possible and provide GIFs and plenty of images to help you on your way to the result, which is just 20–30 minutes away from now.</p><p>I wish you good luck and let’s go!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NOmj82QVgnmk7rfmnADOjA.gif" /><figcaption>The end result we will be able to see very soon.</figcaption></figure><h3>Getting Started</h3><p>Prerequisites:</p><ul><li>Unreal Engine 4.25+</li><li>Visual Studio 2019, please install C++, .NET and UWP development packages.</li><li>Download the <a href="https://www.unrealengine.com/marketplace/en-US/product/paragon-wraith">Paragon: Wraith character pack from the Marketplace</a>. This character pack is a free.</li></ul><p>The setup for the Gameplay Ability Plugin has been covered many times in different tutorials, so if you read them before and already have a setup running, you can skip to the “Cutting A Corner” part where I did something different and simple in contrast to other tutorials. If it is your first time, then it will take you a few copy/paste to get running.</p><p>Start by creating a C++ Unreal Project using the ThirdPersonCharacter template. After creating the project, you need to go to the Edit→Plugins and enable the Gameplay Abilities plugin, then close the Editor.</p><p>After closing, open the YouProjectName.Build.cs file in Visual Studio and include the following dependencies. I’ve highlighted all added code in bold for clarity.</p><pre>using UnrealBuildTool;</pre><pre>public class SimpleGAS : ModuleRules<br>{<br>	public SimpleGAS(ReadOnlyTargetRules Target) : base(Target)<br>	{<br>		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;</pre><pre>		PublicDependencyModuleNames.AddRange(new string[] { &quot;<strong>GameplayAbilities</strong>&quot;, &quot;<strong>GameplayTags</strong>&quot;, &quot;<strong>GameplayTasks</strong>&quot;, &quot;Core&quot;, &quot;CoreUObject&quot;, &quot;Engine&quot;, &quot;InputCore&quot;, &quot;HeadMountedDisplay&quot; });<br>	}<br>}</pre><p>First, we need to declare the AbilitySystemComponent in the ThirdPersonCharacter.h (ASimpleGASCharacter in my project and AYourProjectNameCharacter in your project) header. To keep it organized, you can declare all your component properties in one place.</p><pre>/** Follow camera */<br>	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = &quot;true&quot;))<br>	class UCameraComponent* FollowCamera;</pre><pre><strong>/** Gameplay Ability Component */<br>	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Abilities, meta = (AllowPrivateAccess = &quot;true&quot;))<br>	class UAbilitySystemComponent* AbilitySystemComponent;</strong></pre><p>And on the bottom of the same header file let’s add a getter:</p><pre>public:<br>	/** Returns CameraBoom subobject **/<br>	FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }<br>	/** Returns FollowCamera subobject **/<br>	FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }<br>	/** Returns Ability System Component subobject **/<br>	<strong>FORCEINLINE UAbilitySystemComponent* GetAbilitySystemComponent() const override { return AbilitySystemComponent; }</strong></pre><p>Then declare a StartupAbility property. Once we create our ability blueprint, we will drag and drop it into this property field in the Editor.</p><pre>public:<br>	ASimpleGASCharacter();</pre><pre>	/** Startup Ability to Grant on BeginPlay */<br>	<strong>UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Abilities)<br>	TSubclassOf&lt;class UGameplayAbility&gt; StartupAbility;</strong></pre><p>To initialize and grant Ability on the startup, add the following code to the BeginPlay method.</p><pre>void ASimpleGASCharacter::BeginPlay()<br>{<br>	Super::BeginPlay();</pre><pre>	if ( AbilitySystemComponent &amp;&amp; HasAuthority() )<br>	{<br>		if ( StartupAbility )<br>		{<br>			AbilitySystemComponent-&gt;GiveAbility( FGameplayAbilitySpec(StartupAbility.GetDefaultObject(), 1, 0) );<br>			AbilitySystemComponent-&gt;InitAbilityActorInfo( this, this );<br>		}<br>	}<br>}</pre><p>A ThirdPersonCharacter.h doesn’t have BeginPlay declared out of the box, so we should not forget to add these in the header file somewhere in the protected section, above the rest of the methods there.</p><pre>protected:</pre><pre>	<strong>void BeginPlay() override;</strong></pre><pre><strong>	void PossessedBy(AController* NewController) override;</strong></pre><pre>	/** Resets HMD orientation in VR. */<br>	void OnResetVR();</pre><p>Finally, add the RefreshAbilityActorInfo() method as our character is possessed by a default character controller on the startup.</p><pre>void ASimpleGASCharacter::PossessedBy(AController* NewController)<br>{<br>	Super::PossessedBy(NewController);</pre><pre>	AbilitySystemComponent-&gt;RefreshAbilityActorInfo();<br>}</pre><p>Make sure your project is set as a Startup Project in VS. Press F5 to compile and run the Editor.</p><h3>Cutting a Corner</h3><p>Now let’s do something different from the rest of the tutorials and skip a binding part where we bind the ability activation to the input mappings in our ThirdPersonCharacter.cpp. Instead, we jump directly to our Blueprint class and set it up in an easy way, and here are a few reasons why:</p><ul><li>We will learn a new blueprint node which will activate the ability within the character blueprint. It allows us to be more flexible in the ways we trigger our abilities on and off.</li><li>You may use a different input setup for your project; maybe you decide to play around with controls, so keeping it simple and plugging a pin from one input to another is a decent way to prototype and test things out. Another case if you want to activate your abilities when your character interacts with other non-controllable objects or triggers.</li><li>After all, it is an excuse to learn a bit about ability Gameplay Tags, and the ways how they control almost everything in the GAS. So, by skipping a boring part, let’s jump into the actual ability.</li></ul><h3>Launch Grenade Ability</h3><p>The launching grenade ability will need the following:</p><ul><li>Launching animation Montage (depending on your project, I’ll likely find that most of the basic gameplay mechanics can be done with a few nodes in the graph and an animation montage, so go team up with your Technical Animator friend)</li><li>GA_LaunchGrenade blueprint derived from the Gameplay Ability Base class.</li></ul><p>To start, go to the convenient content folder of your choice and create a new gameplay ability blueprint by right-clicking, selecting the Gameplay Ability Blueprint option, and choosing the Gameplay Ability base class to derive from. Let’s call it GA_LaunchGrenade.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Ki_cbAvvvFjYtT7G5_Wig.gif" /></figure><p>It will help you later on if you establish the naming convention for your assets early, but I suggest going with the following conventions:</p><p>GA_ -Gameplay Ability</p><p>GE_ -Gameplay Effect</p><p>GC_ -Gameplay Cue (that’s for later)</p><p>Open the created blueprint and perform a basic setup by adding some ability logic. For now, it will be a simple print string to show that ability works. And add and assign Ability Tag. You can create any tag you want as long as it will make sense for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Sm5wEQwQ7xsWEnWnk178A.gif" /></figure><p><em>Ability Tag</em> — the unique identifier for ability which is used for actions like activation, deactivation, prohibition and canceling of abilities, and more.</p><p><em>The Tags topic is massive and I will talk about them in more detail later, but for now, let’s pin this and move on to the fun stuff.</em></p><p>As we skipped the binding part, we are now free to go directly to the character blueprint, open it up, and setup ability activation by listening for the ‘G’ input event on our keyboard. Then perform the following:</p><ol><li>Drag an execution pin from the ‘Pressed’ and type “Try Activate Abilities by Tag”. It should suggest the function node of the Ability System Component. Add it to the graph.</li><li>We need to supply a Gameplay Tag into the Gameplay Tag Container input pin. Simply drag our the pin, click Promote to Variable, and give it a name of your choice. Compile blueprint and add our Ability Tag as a default value.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YbMi4MjmP1OmWlHT00JjUw.gif" /></figure><p>3. That’s all! When press G, the event will execute our Try Activate Abilities by Function and will activate LaunchGrenade ability as long as tags are matched. Moreover, you can activate multiple abilities if they share a common Ability Tag. For example, if you come up with the list of abilities that should be activated on a single button press, you can try an “Activate On X button” tag for your ability, in addition to the unique identifier tag. Yes! Ability can be identified by multiple tags.</p><p>Well, before it will work, simply go into your character <em>Class Defaults</em> and select GA_ThrowGrenade as a startup ability. Now press Run and observe the Debug Print once the G key is pressed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0VzKFysuKFGSOg8hKKKllw.gif" /></figure><p>Press Run and observe the Debug Print once the G key is pressed. Now it is time to build on top of the basic setup using Anim Montage and Grenade Actor.</p><h4><strong>Ability content setup</strong></h4><p>Thankfully Epic Games made their Paragon character assets free on the Asset Store. I think this content is a great starting point for beginners to build their prototypes, especially when it comes to finding the set of montages, character skeletons, and animation blueprints. The Wraith has a nice little montage where the suit shoots the grenade from the built-in launcher. This reminds me of Iron Man’s suit. I’d prefer a hand-throw animation where we could control the grenade release timing, but this content is enough for us to learn the basics of <em>Ability Tasks</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fadIoYI9jiKCEe8nCnc7tA.gif" /></figure><p><strong>Setup Guide:</strong></p><ol><li>Go to the character Blueprint and select character mesh. Replace your SK_Mannequin skeletal mesh with the Wraith from the drop-down menu.</li><li>Then up in the Animation settings, select a new Anim Class called Wraith_AnimBlueprint.</li><li>Thanks, Epic! We have our character set up and running. Press Play and give it a try.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UXlV6NtdrCSi3Do-yQv_QQ.gif" /></figure><p>Now let’s go back to our GA_LaunchGrenade ability, and add our first task called “Play Montage and Wait”. For montage to play select Ability_Q_Fire_Montage anim montage. The asset path is:</p><pre>Content/ParagonWraith/Characters/Heroes/Wraith/Animations/Ability_Q_Fire_Montage.uasset</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZ_7HNUt6xZStN7oiLeYGQ.gif" /></figure><p>The ‘<em>Play Montage and Wait’</em> gameplay task is one of the most commonly used tools to build the gameplay with GAS. The concept of the Task is simple as “an action which does not block execution flow and provide a set of events based on the result upon task completion”. Simply meaning that you can start a certain task, continue your logic, and then the task is complete (in this case the montage play is completed) it will allow you to “do something else”, like jumping to the next part of ability logic, another gameplay task or simply End ability on completion. You can run multiple Ability Tasks at the same time, just chain them up using the execution pin in the top right corner.</p><ol><li>The chosen montage sequence also starts with the launcher fully retracted on the first frame, meaning we don’t need to deal with AnimNotifiers and listening to GameplayEvents in this tutorial. That means that as soon as the task has started and the montage started playing we can spawn our grenade actor using another neat function called ‘<em>Spawn Actor For Gameplay Task’</em>. I think the name is self-explanatory. Later, we will use our Grenade actor here.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B2MpqtW51b4uxAObsYTqQQ.gif" /></figure><p><strong>Let’s repeat all the steps again:</strong></p><ol><li>Add ‘<em>Play Montage and Wait’</em> task node and select Ability_Q_Fire_Montage</li><li>Drag the top execution pin to continue Ability execution flow immediately after montage starts playing, add ‘<em>Spawn Actor For Gameplay Task’</em> task node.</li><li>Let’s finish our ability by calling End Ability when the montage stop playing. Add the End Ability node first, then drag all pins from the ‘<em>Play Montage and Wait’</em> events like On Finish, On Cancelled, On Interrupted. That means that if montage play ends for whatever reason, the ability ends there. From that point, a grenade actor and the ability will live their own separate lives.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r9c9yFe2MclfVEOuGurdSA.png" /><figcaption><em>The resulting Gameplay Ability Graph of GA_ThrowGrenade ability</em></figcaption></figure><p>Before moving on to create a Grenade actor, we should finish the setup and get the right spawn location for a Grenade. To do that:</p><ol><li>Open Anim Montage and click on the Skeleton tab in the top right corner.</li><li>Find Muzzle_03 bone and look up its socket name.</li><li>In the Ability Graph call “Get Owning Actor from Actor Info’ — this node returns the owning character of our ability.</li><li>Cast it to Character class, do not cast to your Blueprint version, we need a Skeletal Mesh component, which is defined in Character. That way you will get a base class only and will keep asset reference count low. If you cast to your Blueprint class, the asset reference graph will contain all Blueprint class dependencies as well, which is a good practice to avoided.</li><li>Get Mesh component and get its Socket Location by providing the Muzzle_03 socket name, plug the location into Spawn Actor Gameplay Task.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KbvjbEvEOTsc72g7EznGiQ.gif" /></figure><p><em>Here is how Ability Graph should look:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*00eVEjG-npVlflm-_0IqgQ.png" /></figure><p>We are reaching the culmination of the first part of this tutorial. All that is remaining for today is to create a simple grenade projectile and plug it into our ability.</p><h3>Grenade Actor</h3><p>Create a new Actor and call it BP_Grenade. Add the following components:</p><ol><li>Sphere component. Set scale its scale to 0.1 on each axis. Set a collision preset to Overlap All Dynamic.</li><li>Projectile Movement Component. Set Initial Speed and Max Speed to 1000.0 and set Gravity Scale to 0.2.</li></ol><p>Now we need to create a function that will launch the grenade forward. For this, we will need a projectile velocity equal players forward direction vector multiplied by the initial speed of the projectile.</p><p>Create ‘<em>LaunchInDirection’</em> function with the following logic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QAT4APzWSsY1aczJrgk2fA.png" /><figcaption>BP_Greanade/LaunchInDirection function graph.</figcaption></figure><p>Now let’s go back to the GA_LaunchGrenade ability and select BP_Grenade as our actor to spawn in the <em>‘Spawn Actor For Gameplay Task’</em> node. Task provides us a reference to the spawned actor. On successful spawn, we call the LaunchInDirection function on it and give us a forward vector of our character capsule collision component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oRK-zwGFyI3UvXCNzmpUKw.gif" /></figure><p>And we should not forget to set our character as Instigator for a spawned Grenade. That means our character is responsible for all damage and gameplay effects caused by the spawned grenade. It is also a shortcut reference to our actor, in case we need to trace back from a grenade to the character.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v6WzrJTNFhlg1kE11fCxqw.gif" /></figure><p>Finally, for the Task Owner — add reference to Self. Compile, run, enjoy the result!</p><h3>Result and Key Takeaways</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NOmj82QVgnmk7rfmnADOjA.gif" /></figure><p>Just in a short time, we were able to build a simple grenade launching ability, learn the basics of the Gameplay Ability System, and how simple it is really to create gameplay mechanics with it. But we just touched the tip of the iceberg! There is a lot more to cover the basics of GAS. And we are certainly going to do that in the next parts of the tutorial.</p><p><strong>The key takeaways in this part:</strong></p><ul><li>Gameplay Ability Plugin requires minimal effort a basic ability to read C++ files to set up your first ability.</li><li>Most of the abilities can be done in Blueprints using the built-in functionality of GAS and Unreal. Note how we operate with nodes and added zero custom logic.</li><li>Gameplay Ability is a logic which runs on the owning Actor. It features Gameplay Tags system for simple identification of abilities and setting some rules of what is allowed and prohibited.</li><li>You’re not necessarily need to bind your abilities to the input. You can grant them and activate them almost from anywhere where you have the access to owning actor and its ability system component.</li><li>Gameplay Task is a key building block of abilities. They provide simple way to perform actions, build execution chains from multiple tasks and wait for certain events to happen to change the execution flow of an ability or end it.</li></ul><p>I hope you enjoyed this tutorial and now able to understand the basics of GAS and realize how easy it is to set up. With time you’ll get to know how cool the system is and how much time it saves in prototyping and building compelling gameplay mechanics. I also suggest you team up with an animator friend, as more core gameplay mechanic can be done by a pair of one designer / technical-designer and an animator. If you are an animator or designer, I hope this article helps you start building your prototypes and experiments in Unreal Engine.</p><p>In Part 2 we will cover the topic of Gameplay Effects, expand our Grenade class, and introduce ourselves to the Attributes system.</p><p>Until next time!</p><p>D.S.</p><p><em>A big thanks to my colleague Oliver Stubenrauch, Sr. Technical Designer at Yager for help in the preparation of this material.</em></p><p>Please follow this <a href="https://denismakes.games/2020/10/17/launching-grenades-in-unreal-with-gameplay-ability-system-part-1/">link</a> to the original post on <a href="https://denismakes.games/">denismakes.games</a>.</p><p>Follow me on <a href="https://www.linkedin.com/in/denis-savosin-it/">LinkedIn</a> and <a href="https://twitter.com/denismakesgames">Twitter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3179f38f3730" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>