<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>unreal engine multiplayer Archives - Couch Learn</title>
	<atom:link href="https://couchlearn.com/tag/unreal-engine-multiplayer/feed/" rel="self" type="application/rss+xml" />
	<link>https://couchlearn.com/tag/unreal-engine-multiplayer/</link>
	<description>Detailed Game Programming Tutorials</description>
	<lastBuildDate>Sun, 10 Jan 2021 23:54:33 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.5</generator>

<image>
	<url>https://couchlearn.com/wp-content/uploads/2020/05/cropped-logolarge-32x32.png</url>
	<title>unreal engine multiplayer Archives - Couch Learn</title>
	<link>https://couchlearn.com/tag/unreal-engine-multiplayer/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Multiplayer Damage and Health System in Unreal Engine 4</title>
		<link>https://couchlearn.com/multiplayer-damage-and-health-system-in-unreal-engine-4/</link>
					<comments>https://couchlearn.com/multiplayer-damage-and-health-system-in-unreal-engine-4/#respond</comments>
		
		<dc:creator><![CDATA[Matt]]></dc:creator>
		<pubDate>Thu, 06 Aug 2020 02:20:35 +0000</pubDate>
				<category><![CDATA[Medium Difficulty]]></category>
		<category><![CDATA[Multiplayer]]></category>
		<category><![CDATA[Unreal Engine]]></category>
		<category><![CDATA[health and damage]]></category>
		<category><![CDATA[multiplayer]]></category>
		<category><![CDATA[ue4]]></category>
		<category><![CDATA[ue4 damage]]></category>
		<category><![CDATA[ue4 fps]]></category>
		<category><![CDATA[ue4 health]]></category>
		<category><![CDATA[ue4 health and damage]]></category>
		<category><![CDATA[ue4 multiplayer]]></category>
		<category><![CDATA[ue4 multiplayer fps]]></category>
		<category><![CDATA[unreal engine damage]]></category>
		<category><![CDATA[unreal engine health]]></category>
		<category><![CDATA[unreal engine multiplayer]]></category>
		<guid isPermaLink="false">https://couchlearn.com/?p=1045</guid>

					<description><![CDATA[<p>Unreal Engine 4 contains a powerful multiplayer compatible damage system that works with all actor types. This system easily allows you to create a Multiplayer <a class="mh-excerpt-more" href="https://couchlearn.com/multiplayer-damage-and-health-system-in-unreal-engine-4/" title="Multiplayer Damage and Health System in Unreal Engine 4">[...]</a></p>
<p>The post <a href="https://couchlearn.com/multiplayer-damage-and-health-system-in-unreal-engine-4/">Multiplayer Damage and Health System in Unreal Engine 4</a> appeared first on <a href="https://couchlearn.com">Couch Learn</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Unreal Engine 4 contains a powerful multiplayer compatible damage system that works with all actor types.<br><br>This system easily allows you to create a Multiplayer Damage and Health System in Unreal Engine 4 only using blueprints.</p>



<h3 class="wp-block-heading">Prerequisites</h3>



<p>This guide expects that you understand how to use basic nodes such as branch, get player controller and input actions / events.<br><br>If you do not know how to use input actions in Unreal Engine 4 <a href="https://couchlearn.com/how-to-use-input-actions-and-input-axis-mappings-in-your-unreal-engine-4-game/">click here to read our guide.</a><br><br>This guide also expects that you know what a line trace is and how to set them up for a first person style game.<br><br>If you do not know how to setup first person line traces <a href="https://couchlearn.com/basic-first-person-line-trace-in-unreal-engine-4/">click here to read our guide.</a></p>



<h3 class="wp-block-heading">How Unreal&#8217;s Damage System works</h3>



<h4 class="wp-block-heading">How to Deal Damage</h4>



<p>The most basic way to deal damage to another actor is to use the &#8220;Apply Damage&#8221; node.</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="306" height="286" src="https://couchlearn.com/wp-content/uploads/2020/08/image.png" alt="The apply damage node with the damage set to 15.0" class="wp-image-1197" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image.png 306w, https://couchlearn.com/wp-content/uploads/2020/08/image-300x280.png 300w" sizes="(max-width: 306px) 100vw, 306px" /></figure>



<p>Here are the important variables to set:<br><br><strong>Damaged Actor</strong> &#8211; The actor that you want to damage<br><strong>Base Damage</strong> &#8211; The amount of damage to apply to the damaged actor<br><strong>Damage Causer</strong> &#8211; The actor that applied the damage to the damaged actor</p>



<h4 class="wp-block-heading">How to Detect Damage</h4>



<p>When added to any actors event graph, the &#8220;Event AnyDamage&#8221; event node runs every time the actor is damaged.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="189" height="193" src="https://couchlearn.com/wp-content/uploads/2020/08/image-1.png" alt="The AnyDamage event that runs every time your actor is damaged" class="wp-image-1199"/></figure>



<p>Here are the important variables to use from the event node:<br><br><strong>Damage</strong> &#8211; The amount of damage that is detected<br><strong>Damage Causer</strong> &#8211; The actor that dealt the damage</p>



<h3 class="wp-block-heading">Creating the Weapon Damage Nodes</h3>



<p><strong>We recommend using the default First Person Shooter template for this guide. </strong><br><br>This damage system works will all game types but when learning a new system it is easier to have a template that works well before you start.<br><br>The First Person Shooter template has a player character setup with movement, mouse aiming, arm and gun models and animations.</p>



<h4 class="wp-block-heading">Requesting to Shoot to the server</h4>



<p>Firstly, to make the weapon damage run correctly on multiplayer, create a new custom event called &#8220;Net Shoot Weapon&#8221;.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="410" height="122" src="https://couchlearn.com/wp-content/uploads/2020/08/image-2.png" alt="Creating the custom event to fire the weapon on the server" class="wp-image-1200" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-2.png 410w, https://couchlearn.com/wp-content/uploads/2020/08/image-2-300x89.png 300w" sizes="(max-width: 410px) 100vw, 410px" /></figure>



<p>Then click the new event (Net Shoot Weapon) and in the detail panel on the right of the screen change the &#8220;Replicates&#8221; drop down box to &#8220;Run on Server&#8221;.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="476" height="283" src="https://couchlearn.com/wp-content/uploads/2020/08/image-4.png" alt="Setting the Net Shoot Event to run on the server" class="wp-image-1202" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-4.png 476w, https://couchlearn.com/wp-content/uploads/2020/08/image-4-300x178.png 300w" sizes="(max-width: 476px) 100vw, 476px" /></figure>



<p>Changing this setting will now run this event from the client to the server. This prevents cheating as all damage and collision checking will be done server side.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="181" height="104" src="https://couchlearn.com/wp-content/uploads/2020/08/image-6.png" alt="The custom network compatible Net Shoot Weapon event" class="wp-image-1207"/><figcaption>This event called on the client is only run on the server</figcaption></figure>



<p>Next create an InputAction Fire event (included in the first person shooter template) and create a Net Shoot Weapon node to the Pressed pin.<br><br>This will send a message to the server to shoot your gun and calculate the </p>



<figure class="wp-block-image size-large"><img decoding="async" width="452" height="170" src="https://couchlearn.com/wp-content/uploads/2020/08/image-3.png" alt="Telling the server to fire when the fire button event is pressed" class="wp-image-1201" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-3.png 452w, https://couchlearn.com/wp-content/uploads/2020/08/image-3-300x113.png 300w" sizes="(max-width: 452px) 100vw, 452px" /></figure>



<p>Finally for this section to be complete, connect the animation and sound effect blueprint nodes from the template to the Net Shoot Weapon execution pin.<br><br>This complete section will look like this:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="421" src="https://couchlearn.com/wp-content/uploads/2020/08/image-5-1024x421.png" alt="The complete firing code on the client" class="wp-image-1206" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-5-1024x421.png 1024w, https://couchlearn.com/wp-content/uploads/2020/08/image-5-300x123.png 300w, https://couchlearn.com/wp-content/uploads/2020/08/image-5-768x316.png 768w, https://couchlearn.com/wp-content/uploads/2020/08/image-5.png 1137w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">Syncing the Animation and Sounds</h4>



<p>The animation and sound effects running on the previous step don&#8217;t currently run for other players.<br><br>To play the animation and sound for this player on everyone else&#8217;s screens we need to create a multi cast event.<br><br>Firstly, add a new custom event named &#8220;Multi Weapon Animation&#8221;.</p>



<figure class="wp-block-image"><img decoding="async" src="https://couchlearn.com/wp-content/uploads/2020/08/image-2.png" alt="Creating the custom event to fire the weapon on the server"/></figure>



<p>And change the &#8220;Replicates&#8221; to &#8220;Multicast&#8221;.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="479" height="247" src="https://couchlearn.com/wp-content/uploads/2020/08/image-7.png" alt="Changing the replicates property of the event to Multicast" class="wp-image-1208" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-7.png 479w, https://couchlearn.com/wp-content/uploads/2020/08/image-7-300x155.png 300w" sizes="(max-width: 479px) 100vw, 479px" /></figure>



<p>Create a branch node, a Get Player Controller node and a Get Controller node.<br><br>From the Get Player Controller node create an equals node and connect the &#8220;Get Controller&#8221; node to the bottom pin as shown below.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="428" height="305" src="https://couchlearn.com/wp-content/uploads/2020/08/image-9.png" alt="Preventing the animation and sound from playing twice on the client" class="wp-image-1210" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-9.png 428w, https://couchlearn.com/wp-content/uploads/2020/08/image-9-300x214.png 300w" sizes="(max-width: 428px) 100vw, 428px" /><figcaption>This is done to prevent the animation playing twice on the owning players screen.</figcaption></figure>



<p>The last nodes required for this step can be copied and pasted from the step above.<br><br>The complete section looks like this:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="433" src="https://couchlearn.com/wp-content/uploads/2020/08/image-10-1024x433.png" alt="The complete multicast animation and sound effects event for the clients" class="wp-image-1211" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-10-1024x433.png 1024w, https://couchlearn.com/wp-content/uploads/2020/08/image-10-300x127.png 300w, https://couchlearn.com/wp-content/uploads/2020/08/image-10-768x325.png 768w, https://couchlearn.com/wp-content/uploads/2020/08/image-10.png 1097w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Multicast events run for all clients</figcaption></figure>



<h4 class="wp-block-heading">Server-side Weapon Shooting</h4>



<p>Firstly, from the &#8220;Net Shoot Weapon&#8221; event created earlier in this guide, we need to create a &#8220;Multi Weapon Animation&#8221; node and connect it together. <br><br>This will sync the animation and sound to all clients on the server whenever a player shoots.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="464" height="135" src="https://couchlearn.com/wp-content/uploads/2020/08/image-11.png" alt="Running the Multi Weapon Animation event from the server to sync all animations and sounds for all clients" class="wp-image-1213" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-11.png 464w, https://couchlearn.com/wp-content/uploads/2020/08/image-11-300x87.png 300w" sizes="(max-width: 464px) 100vw, 464px" /></figure>



<p>To damage another actor when the request is received, we first will need to use a Line Trace for Objects node.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="589" src="https://couchlearn.com/wp-content/uploads/2020/08/image-27-1024x589.png" alt="Connecting the line trace for objects node to the server shoot weapon event" class="wp-image-1241" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-27-1024x589.png 1024w, https://couchlearn.com/wp-content/uploads/2020/08/image-27-300x173.png 300w, https://couchlearn.com/wp-content/uploads/2020/08/image-27-768x442.png 768w, https://couchlearn.com/wp-content/uploads/2020/08/image-27.png 1055w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>This line trace runs on the server when called and uses the server&#8217;s state to prevent cheating.</figcaption></figure>



<p>If you do not know how to setup a line trace <a href="https://couchlearn.com/basic-first-person-line-trace-in-unreal-engine-4/">click here to read our guide on first person line traces in Unreal Engine 4</a><br><br>From the line trace we need to create an &#8220;Apply Damage&#8221; node and connect the &#8220;Hit Actor&#8221; pin from the &#8220;Break Hit Result&#8221; node to the &#8220;Damaged Actor&#8221; pin on the &#8220;Apply Damage&#8221; node.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="529" height="400" src="https://couchlearn.com/wp-content/uploads/2020/08/image-29.png" alt="A close up of the break hit result connecting to the Apply Damage node" class="wp-image-1243" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-29.png 529w, https://couchlearn.com/wp-content/uploads/2020/08/image-29-300x227.png 300w" sizes="(max-width: 529px) 100vw, 529px" /></figure>



<p>Set the &#8220;Base Damage&#8221; value to the damage that you want your weapon to deal. (We used 15.0 in this case)</p>



<figure class="wp-block-image size-large"><img decoding="async" width="299" height="127" src="https://couchlearn.com/wp-content/uploads/2020/08/image-30.png" alt="Setting the base damage to 15.0 of the Apply Damage node" class="wp-image-1244"/></figure>



<p>Lastly, create a Self node and connect it to the &#8220;Damage Causer&#8221; pin.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="410" height="109" src="https://couchlearn.com/wp-content/uploads/2020/08/image-32.png" alt="Creating a reference to self" class="wp-image-1246" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-32.png 410w, https://couchlearn.com/wp-content/uploads/2020/08/image-32-300x80.png 300w" sizes="(max-width: 410px) 100vw, 410px" /></figure>



<p>After all these steps, the line trace connections should look like this:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="887" height="565" src="https://couchlearn.com/wp-content/uploads/2020/08/image-28.png" alt="The last step to complete the Line Trace for Objects node and apply damage node." class="wp-image-1242" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-28.png 887w, https://couchlearn.com/wp-content/uploads/2020/08/image-28-300x191.png 300w, https://couchlearn.com/wp-content/uploads/2020/08/image-28-768x489.png 768w" sizes="(max-width: 887px) 100vw, 887px" /></figure>



<p>And here is the complete Net Shoot Weapon event blueprint nodes:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="449" src="https://couchlearn.com/wp-content/uploads/2020/08/image-31-1024x449.png" alt="The complete server side system to apply damage to the target actor" class="wp-image-1245" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-31-1024x449.png 1024w, https://couchlearn.com/wp-content/uploads/2020/08/image-31-300x132.png 300w, https://couchlearn.com/wp-content/uploads/2020/08/image-31-768x337.png 768w, https://couchlearn.com/wp-content/uploads/2020/08/image-31.png 1373w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">Receiving the Damage</h4>



<p>Firstly create an AnyDamage event in the actor that you want to receive damage.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="198" height="188" src="https://couchlearn.com/wp-content/uploads/2020/08/image-34.png" alt="Creating the AnyDamage event" class="wp-image-1249"/></figure>



<p>Create a new variable named &#8220;Health&#8221; with the type of float. This will be used to store the amount of health the actor has.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="348" height="122" src="https://couchlearn.com/wp-content/uploads/2020/08/image-35.png" alt="Creating the health variable" class="wp-image-1250" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-35.png 348w, https://couchlearn.com/wp-content/uploads/2020/08/image-35-300x105.png 300w" sizes="(max-width: 348px) 100vw, 348px" /></figure>



<p>Set the default value of the &#8220;Health&#8221; variable to 100 (or whichever you want your actors max health to be)</p>



<figure class="wp-block-image size-large"><img decoding="async" width="330" height="60" src="https://couchlearn.com/wp-content/uploads/2020/08/image-36.png" alt="Setting the default value of the health variable to 100" class="wp-image-1251" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-36.png 330w, https://couchlearn.com/wp-content/uploads/2020/08/image-36-300x55.png 300w" sizes="(max-width: 330px) 100vw, 330px" /></figure>



<p>Next create a Get node for Health, subtract Damage from Health and then set Health to this new value.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="516" height="259" src="https://couchlearn.com/wp-content/uploads/2020/08/image-37.png" alt="Calculating the remaining health after dealing the damage" class="wp-image-1252" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-37.png 516w, https://couchlearn.com/wp-content/uploads/2020/08/image-37-300x151.png 300w" sizes="(max-width: 516px) 100vw, 516px" /></figure>



<p>From the Set Health node create a &#8220;Less than or Equal&#8221; node, create a branch node and connect them together. This checks if the player&#8217;s health is less than or equal to zero after taking the damage</p>



<figure class="wp-block-image size-large"><img decoding="async" width="617" height="269" src="https://couchlearn.com/wp-content/uploads/2020/08/image-38.png" alt="Checking if the players new health is less than or equal to zero" class="wp-image-1253" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-38.png 617w, https://couchlearn.com/wp-content/uploads/2020/08/image-38-300x131.png 300w" sizes="(max-width: 617px) 100vw, 617px" /><figcaption>Checking if the actor has no health remaining</figcaption></figure>



<p>Finally, on the True execution pin create a &#8220;SetActorLocation&#8221; node and set the New Location value to where you want your actors to respawn when they run out of health.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="309" src="https://couchlearn.com/wp-content/uploads/2020/08/image-39-1024x309.png" alt="If the actor's health is less than or equal to zero" class="wp-image-1255" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-39-1024x309.png 1024w, https://couchlearn.com/wp-content/uploads/2020/08/image-39-300x91.png 300w, https://couchlearn.com/wp-content/uploads/2020/08/image-39-768x232.png 768w, https://couchlearn.com/wp-content/uploads/2020/08/image-39.png 1127w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Here is the complete Event AnyDamage blueprint nodes:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="200" src="https://couchlearn.com/wp-content/uploads/2020/08/image-40-1024x200.png" alt="The complete Event AnyDamage blueprint nodes" class="wp-image-1256" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-40-1024x200.png 1024w, https://couchlearn.com/wp-content/uploads/2020/08/image-40-300x59.png 300w, https://couchlearn.com/wp-content/uploads/2020/08/image-40-768x150.png 768w, https://couchlearn.com/wp-content/uploads/2020/08/image-40.png 1410w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Demonstration</h3>



<figure class="wp-block-image size-large"><img decoding="async" width="800" height="269" src="https://couchlearn.com/wp-content/uploads/2020/08/healthdamage.gif" alt="The multiplayer FPS health and damage system working in engine." class="wp-image-1257"/><figcaption>Players being hit with damage and respawning when running out of health.</figcaption></figure>



<p><em>To visualise the health of the hit player easier we added a &#8220;Print String&#8221; node here:</em></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="295" src="https://couchlearn.com/wp-content/uploads/2020/08/image-41-1024x295.png" alt="Easily debugging player health by adding a print string node" class="wp-image-1258" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-41-1024x295.png 1024w, https://couchlearn.com/wp-content/uploads/2020/08/image-41-300x86.png 300w, https://couchlearn.com/wp-content/uploads/2020/08/image-41-768x221.png 768w, https://couchlearn.com/wp-content/uploads/2020/08/image-41.png 1416w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Download the Project Files</h3>



<script src="https://gumroad.com/js/gumroad-embed.js"></script>
<div class="gumroad-product-embed" data-gumroad-product-id="hqpJJ"><a href="https://gumroad.com/l/hqpJJ">Loading&#8230;</a></div>



<h3 class="wp-block-heading">Conclusion</h3>



<p>Now your game or project has a fully multiplayer compatible damage system all using blueprints!</p>



<h4 class="wp-block-heading"><strong>Expanding this System</strong></h4>



<p>To improve this system you could add a widget to the screen showing when a player is defeated and with what weapon they were defeated by.<br><br>Another way to improve this shooter style game would be to add attenuation to the shooting sound effects. <br><br>This would reduce the volume over distance and make the game more realistic. <a href="https://couchlearn.com/simple-audio-attenuation-in-unreal-engine-4/">Click here to check out our guide on attenuation in Unreal Engine 4.</a><br><br>Lastly, try expanding from this guide by creating AI character with health and damage with our easy AI movement guide. <a href="https://couchlearn.com/easy-ai-movement-in-unreal-engine-4/">https://couchlearn.com/easy-ai-movement-in-unreal-engine-4/</a></p>



<h4 class="wp-block-heading">Further Reading</h4>



<p>Unreal Engine&#8217;s blog post on their damage system: <a href="https://www.unrealengine.com/en-US/blog/damage-in-ue4#:~:text=Damage%20support%20is%20a%20feature,your%20damage%20model%20when%20needed.">https://www.unrealengine.com/en-US/blog/damage-in-ue4#:~:text=Damage%20support%20is%20a%20feature,your%20damage%20model%20when%20needed.</a><br><br>The full damage blueprint node documentation can be found here: <a href="https://docs.unrealengine.com/en-US/BlueprintAPI/Game/Damage/index.html">https://docs.unrealengine.com/en-US/BlueprintAPI/Game/Damage/index.html</a></p>
<p>The post <a href="https://couchlearn.com/multiplayer-damage-and-health-system-in-unreal-engine-4/">Multiplayer Damage and Health System in Unreal Engine 4</a> appeared first on <a href="https://couchlearn.com">Couch Learn</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://couchlearn.com/multiplayer-damage-and-health-system-in-unreal-engine-4/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to use Multiplayer Sessions in your Unreal Engine 4 game</title>
		<link>https://couchlearn.com/multiplayer-sessions-in-your-unreal-engine-4-game/</link>
					<comments>https://couchlearn.com/multiplayer-sessions-in-your-unreal-engine-4-game/#comments</comments>
		
		<dc:creator><![CDATA[Matt]]></dc:creator>
		<pubDate>Wed, 31 Jul 2019 17:25:05 +0000</pubDate>
				<category><![CDATA[Medium Difficulty]]></category>
		<category><![CDATA[Multiplayer]]></category>
		<category><![CDATA[Unreal Engine]]></category>
		<category><![CDATA[multiplayer]]></category>
		<category><![CDATA[multiplayer session]]></category>
		<category><![CDATA[sessions]]></category>
		<category><![CDATA[ue4]]></category>
		<category><![CDATA[ue4 multiplayer]]></category>
		<category><![CDATA[unreal engine]]></category>
		<category><![CDATA[unreal engine multiplayer]]></category>
		<category><![CDATA[unreal engine sessions]]></category>
		<guid isPermaLink="false">https://couchlearn.com/?p=382</guid>

					<description><![CDATA[<p>The Session System in Unreal Engine 4 gives you access to many powerful online features such as the server browser, setting a maximum player limits, <a class="mh-excerpt-more" href="https://couchlearn.com/multiplayer-sessions-in-your-unreal-engine-4-game/" title="How to use Multiplayer Sessions in your Unreal Engine 4 game">[...]</a></p>
<p>The post <a href="https://couchlearn.com/multiplayer-sessions-in-your-unreal-engine-4-game/">How to use Multiplayer Sessions in your Unreal Engine 4 game</a> appeared first on <a href="https://couchlearn.com">Couch Learn</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>The Session System in Unreal Engine 4 gives you access to many powerful online features such as the server browser, setting a maximum player limits, setting private and public slots and much more. </p>



<p>Using this system is very straightforward and only takes a few blueprint nodes to get working. </p>



<p>In this guide I will show you how to setup multiplayer in Unreal Engine 4 using the session system. We will setup a simple session and connect to it through another player.</p>



<h3 class="wp-block-heading">Online and LAN Support</h3>



<p>Unreal Engine&#8217;s default online subsystem can not find sessions outside of the local network the player is in.<br><br>To find and connect to sessions outside of your local network without a direct IP address connection you will need to use a different subsystem such as Steam.<br><br><a href="https://docs.unrealengine.com/en-US/Programming/Online/Steam/index.html"><em>Click here to read the documentation for the Steam subsystem</em></a></p>



<h2 class="wp-block-heading">Starting a Multiplayer Session</h2>



<h3 class="wp-block-heading">Creating the Session</h3>



<p>To start I created a simple widget with two buttons. One is host and one is play.</p>



<p>On the host button event use the create session blueprint node.</p>



<figure class="wp-block-image"><img decoding="async" width="545" height="167" src="https://couchlearn.com/wp-content/uploads/2019/07/image-81.png" alt="Creating the session" class="wp-image-643" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-81.png 545w, https://couchlearn.com/wp-content/uploads/2019/07/image-81-300x92.png 300w" sizes="(max-width: 545px) 100vw, 545px" /></figure>



<p>On the player controller pin, connect a &#8220;Get Player Controller&#8221; node and for the public connections pin set it to the maximum amount of players you want for this game. </p>



<p><strong>Public connections is the maximum amount of players that can be connected to your server at once.</strong></p>



<figure class="wp-block-image"><img decoding="async" width="543" height="169" src="https://couchlearn.com/wp-content/uploads/2019/07/image-82.png" alt="Adding the nodes to the Create Session node" class="wp-image-644" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-82.png 543w, https://couchlearn.com/wp-content/uploads/2019/07/image-82-300x93.png 300w" sizes="(max-width: 543px) 100vw, 543px" /></figure>



<p>If &#8220;Use Lan&#8221; is checked the session you create will be only available on your local internet. </p>



<h3 class="wp-block-heading">Opening Levels to Multiplayer</h3>



<p>To create a multiplayer game using your level, add a new &#8220;Open Level&#8221; node and set the &#8220;Level Name&#8221; pin to the level you wish to play on. In my case this is FirstPersonExampleMap.</p>



<figure class="wp-block-image"><img decoding="async" width="247" height="145" src="https://couchlearn.com/wp-content/uploads/2019/07/image-84.png" alt="Opening the level" class="wp-image-646"/></figure>



<p>The important step is to click the triangle at the bottom of this node to expose the extra settings.</p>



<figure class="wp-block-image"><img decoding="async" width="243" height="135" src="https://couchlearn.com/wp-content/uploads/2019/07/image-86.png" alt="Additional settings when opening the level" class="wp-image-649"/></figure>



<p>The &#8220;Absolute&#8221; checkbox and the &#8220;Options&#8221; text box pins are now visible. In the Options pin type exactly:</p>



<pre class="wp-block-code"><code>?listen</code></pre>



<p>This code sets the level up to listen for multiplayer connections as a Listen Server.</p>



<figure class="wp-block-image"><img decoding="async" width="249" height="205" src="https://couchlearn.com/wp-content/uploads/2019/07/image-85.png" alt="Adding ?listen to the additional settings." class="wp-image-648"/></figure>



<p>With these steps complete, the code should look like this.</p>



<figure class="wp-block-image"><img decoding="async" width="799" height="244" src="https://couchlearn.com/wp-content/uploads/2019/07/image-83.png" alt="Complete host code" class="wp-image-645" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-83.png 799w, https://couchlearn.com/wp-content/uploads/2019/07/image-83-300x92.png 300w, https://couchlearn.com/wp-content/uploads/2019/07/image-83-768x235.png 768w" sizes="(max-width: 799px) 100vw, 799px" /></figure>



<h2 class="wp-block-heading">Connecting to your Multiplayer Session</h2>



<h3 class="wp-block-heading">Finding Sessions</h3>



<p>Finding sessions using blueprints is simple. The Find Sessions node handles all this for us. It outputs different execution pins based on if it succeeded or failed and the results that it found as an array.</p>



<p>If you aren&#8217;t familiar with arrays <a href="https://couchlearn.com/how-to-use-loops-and-arrays-unreal-engine-4/">click here to learn about arrays in Unreal Engine 4.</a></p>



<p>To start I created the Find Sessions node attached to the Play button in my widget.</p>



<figure class="wp-block-image"><img decoding="async" width="509" height="165" src="https://couchlearn.com/wp-content/uploads/2019/07/image-87.png" alt="Find sessions node" class="wp-image-650" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-87.png 509w, https://couchlearn.com/wp-content/uploads/2019/07/image-87-300x97.png 300w" sizes="(max-width: 509px) 100vw, 509px" /></figure>



<p>On the player controller pin connect a &#8220;Get Player Controller&#8221; node and the Max Results pin is set to 100.</p>



<figure class="wp-block-image"><img decoding="async" width="517" height="180" src="https://couchlearn.com/wp-content/uploads/2019/07/image-88.png" alt="Adding nodes to the Find Sessions node" class="wp-image-652" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-88.png 517w, https://couchlearn.com/wp-content/uploads/2019/07/image-88-300x104.png 300w" sizes="(max-width: 517px) 100vw, 517px" /></figure>



<p>The Use Lan checkbox, if checked, will only search for sessions in your local area.</p>



<h3 class="wp-block-heading">Joining the Session</h3>



<p>To join a session in Unreal Engine 4, create a Join Session node.</p>



<p>This node requires the player&#8217;s controller and a session from the Find Sessions array in the previous step.</p>



<figure class="wp-block-image"><img decoding="async" width="248" height="135" src="https://couchlearn.com/wp-content/uploads/2019/07/image-89.png" alt="Join session node" class="wp-image-653"/></figure>



<p>Firstly I will create a Get Player Controller node and attach it to the Join Session node.</p>



<figure class="wp-block-image"><img decoding="async" width="276" height="211" src="https://couchlearn.com/wp-content/uploads/2019/07/image-90.png" alt="Adding the player controller to the Join Session node" class="wp-image-654"/></figure>



<p>From the Results output pin of the Find Sessions node in the previous step I created a Get node. This will find the first session in the list.</p>



<figure class="wp-block-image"><img decoding="async" width="548" height="319" src="https://couchlearn.com/wp-content/uploads/2019/07/image-91.png" alt="Getting session results from the Find Session node" class="wp-image-655" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-91.png 548w, https://couchlearn.com/wp-content/uploads/2019/07/image-91-300x175.png 300w" sizes="(max-width: 548px) 100vw, 548px" /></figure>



<p>This is then attached to the Search Results input pin of the Join Session node.</p>



<figure class="wp-block-image"><img decoding="async" width="551" height="320" src="https://couchlearn.com/wp-content/uploads/2019/07/image-94.png" alt="Attaching the found session to the join session node." class="wp-image-658" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-94.png 551w, https://couchlearn.com/wp-content/uploads/2019/07/image-94-300x174.png 300w" sizes="(max-width: 551px) 100vw, 551px" /></figure>



<p>Finally, the Join Session node is attached to the On Success execution pin of the Find Sessions node.</p>



<figure class="wp-block-image"><img decoding="async" width="552" height="316" src="https://couchlearn.com/wp-content/uploads/2019/07/image-93.png" alt="Attaching the join session node to the on success pin of the find sessions node" class="wp-image-657" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-93.png 552w, https://couchlearn.com/wp-content/uploads/2019/07/image-93-300x172.png 300w" sizes="(max-width: 552px) 100vw, 552px" /></figure>



<h3 class="wp-block-heading">Opening the Game Clients</h3>



<p>In Unreal Engine 4, there is a drop down menu next to the play button which gives you access to multiplayer options.</p>



<p>On this menu make sure &#8220;New Editor Window (PIE)&#8221; is selected and the &#8220;Number of Players&#8221; slider is set to anything above 1.</p>



<p>Next, click the Advanced Settings button at the bottom of the menu.</p>



<figure class="wp-block-image"><img decoding="async" width="425" height="465" src="https://couchlearn.com/wp-content/uploads/2019/07/image-95.png" alt="Play settings in Unreal Engine 4" class="wp-image-659" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-95.png 425w, https://couchlearn.com/wp-content/uploads/2019/07/image-95-274x300.png 274w" sizes="(max-width: 425px) 100vw, 425px" /></figure>



<p>Near the bottom of the Advanced Settings menu, find the a section called Multiplayer Options.</p>



<p><strong>Un-tick</strong> the checkbox &#8220;Auto Connect to Server&#8221;. This prevents the server auto connecting without the session system.</p>



<figure class="wp-block-image"><img decoding="async" width="669" height="217" src="https://couchlearn.com/wp-content/uploads/2019/07/image-96.png" alt="Advanced play settings" class="wp-image-660" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-96.png 669w, https://couchlearn.com/wp-content/uploads/2019/07/image-96-300x97.png 300w" sizes="(max-width: 669px) 100vw, 669px" /></figure>



<p>Finally, when you press the play button in your editor two clients will open.</p>



<figure class="wp-block-image"><img decoding="async" width="1024" height="550" src="https://couchlearn.com/wp-content/uploads/2019/07/image-97-1024x550.png" alt="Playing with two clients" class="wp-image-661" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-97-1024x550.png 1024w, https://couchlearn.com/wp-content/uploads/2019/07/image-97-300x161.png 300w, https://couchlearn.com/wp-content/uploads/2019/07/image-97-768x413.png 768w, https://couchlearn.com/wp-content/uploads/2019/07/image-97.png 1837w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>The custom widget discussed earlier,  displays the Host button and Play buttons.</p>



<p>On the first client I pressed the Host button. This reloaded the level.</p>



<figure class="wp-block-image"><img decoding="async" width="1024" height="576" src="https://couchlearn.com/wp-content/uploads/2019/07/image-98-1024x576.png" alt="Hosting the game" class="wp-image-662" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-98-1024x576.png 1024w, https://couchlearn.com/wp-content/uploads/2019/07/image-98-300x169.png 300w, https://couchlearn.com/wp-content/uploads/2019/07/image-98-768x432.png 768w, https://couchlearn.com/wp-content/uploads/2019/07/image-98.png 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>On the second client I pressed the Play button and waited until the Find Sessions node had finished searching for multiplayer sessions.</p>



<p>Once this finished it auto connected me into the first clients game.</p>



<figure class="wp-block-image"><img decoding="async" width="1024" height="486" src="https://couchlearn.com/wp-content/uploads/2019/07/image-100-1024x486.png" alt="Joining the game and showing two players connected to the same game" class="wp-image-664" srcset="https://couchlearn.com/wp-content/uploads/2019/07/image-100-1024x486.png 1024w, https://couchlearn.com/wp-content/uploads/2019/07/image-100-300x142.png 300w, https://couchlearn.com/wp-content/uploads/2019/07/image-100-768x364.png 768w, https://couchlearn.com/wp-content/uploads/2019/07/image-100.png 1891w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Connecting to Sessions Outside your Local Internet Network</h3>



<p>The session created in this guide will can be used in your local network and through the internet.</p>



<p>If you connecting to a session in your local internet, you do not have to do anything else.</p>



<p>If you wish to host your session to global internet users, make sure to <strong>port forward</strong> UDP/TCP 7777. Setting up port forwarding is different per router so check your specific router instructions.</p>



<p><a href="https://en.wikipedia.org/wiki/Port_forwarding">If you don&#8217;t know what port forwarding is click here. </a></p>



<h2 class="wp-block-heading">Download the Project Files</h2>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<script src="https://gumroad.com/js/gumroad-embed.js"></script>
<div class="gumroad-product-embed" data-gumroad-product-id="EvfoJ"><a href="https://gumroad.com/l/EvfoJ">Loading&#8230;</a></div>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<script src="https://gumroad.com/js/gumroad-embed.js"></script>
<div class="gumroad-product-embed" data-gumroad-product-id="rump"><a href="https://gumroad.com/l/rump">Loading&#8230;</a></div>
</div>
</div>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Your multiplayer session is created and players can join!</p>



<p>This guide only brushed over the multiplayer system to start with sessions in Unreal Engine 4. </p>



<p>To learn more about replication and the session system, the Unreal Engine documentation as it is a good place to start. </p>



<p><a href="https://wiki.unrealengine.com/Replication">Click here to read more about Replication. </a></p>



<p><a href="https://docs.unrealengine.com/en-US/Engine/Blueprints/UserGuide/OnlineNodes/index.html">Clic</a><a href="https://docs.unrealengine.com/en-US/Engine/Blueprints/UserGuide/OnlineNodes/index.html"></a><a href="https://docs.unrealengine.com/en-US/Engine/Blueprints/UserGuide/OnlineNodes/index.html">k here to read more about the session system nodes.</a></p>



<h3 class="wp-block-heading">Expanding the System</h3>



<p>To challenge yourself, try create a widget that fills itself with the results of the Find Session nodes. </p>



<p>This, if done correctly, will create a server browser similar to the ones found in games such as Team Fortress 2, Counter Strike and many more.</p>



<figure class="wp-block-image"><img decoding="async" src="http://i.imgur.com/ii81Q.png" alt="Image result for server browser tf2"/></figure>
<p>The post <a href="https://couchlearn.com/multiplayer-sessions-in-your-unreal-engine-4-game/">How to use Multiplayer Sessions in your Unreal Engine 4 game</a> appeared first on <a href="https://couchlearn.com">Couch Learn</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://couchlearn.com/multiplayer-sessions-in-your-unreal-engine-4-game/feed/</wfw:commentRss>
			<slash:comments>26</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: couchlearn.com @ 2026-04-15 11:49:17 by W3 Total Cache
-->