<?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>vr Archives - Couch Learn</title>
	<atom:link href="https://couchlearn.com/tag/vr/feed/" rel="self" type="application/rss+xml" />
	<link>https://couchlearn.com/tag/vr/</link>
	<description>Detailed Game Programming Tutorials</description>
	<lastBuildDate>Wed, 19 Oct 2022 17:14:26 +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>vr Archives - Couch Learn</title>
	<link>https://couchlearn.com/tag/vr/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to make VR Interactable UI Widgets in Unreal Engine 4</title>
		<link>https://couchlearn.com/how-to-make-vr-interactable-ui-widgets-in-unreal-engine-4/</link>
					<comments>https://couchlearn.com/how-to-make-vr-interactable-ui-widgets-in-unreal-engine-4/#comments</comments>
		
		<dc:creator><![CDATA[Matt]]></dc:creator>
		<pubDate>Tue, 27 Apr 2021 17:53:40 +0000</pubDate>
				<category><![CDATA[Unreal Engine]]></category>
		<category><![CDATA[VR]]></category>
		<category><![CDATA[ue4 virtual reality]]></category>
		<category><![CDATA[ue4 vr]]></category>
		<category><![CDATA[ue4 vr widgets]]></category>
		<category><![CDATA[virtual reality]]></category>
		<category><![CDATA[virtual reality widgets]]></category>
		<category><![CDATA[vr]]></category>
		<category><![CDATA[vr widgets]]></category>
		<guid isPermaLink="false">https://couchlearn.com/?p=1488</guid>

					<description><![CDATA[<p>Motion controllers are an important feature of modern virtual reality game design. Interacting with Widgets using motion controllers in Unreal Engine 4 is easy and <a class="mh-excerpt-more" href="https://couchlearn.com/how-to-make-vr-interactable-ui-widgets-in-unreal-engine-4/" title="How to make VR Interactable UI Widgets in Unreal Engine 4">[...]</a></p>
<p>The post <a href="https://couchlearn.com/how-to-make-vr-interactable-ui-widgets-in-unreal-engine-4/">How to make VR Interactable UI Widgets in Unreal Engine 4</a> appeared first on <a href="https://couchlearn.com">Couch Learn</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Motion controllers are an important feature of modern virtual reality game design. <br><br>Interacting with Widgets using motion controllers in Unreal Engine 4 is easy and requires very little changes to your existing Widgets and character actors.<br><br>In this guide we will be creating a motion controller compatible VR Interactable UI Widgets in Unreal Engine 4.</p>



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



<p>To follow this guide we recommend you know the basics of Unreal Engine 4, using the widget UI system and basic knowledge of blueprints and actors.<br><br><strong>This guide uses the UE4 VR Template built into Unreal Engine 4. <br></strong><br>To follow along exactly to the guide you will need to create or use a project that was created using the VR Template. <br><br><strong>Click on the links below to learn about these topics</strong>:<br>&#8211; <a href="https://docs.unrealengine.com/en-US/InteractiveExperiences/UMG/HowTo/CreatingWidgets/index.html">Creating and using Widgets in Unreal Engine 4</a><br><a href="https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Blueprints/BP_HowTo/BasicUsage/index.html">&#8211; Blueprint basics in Unreal Engine 4</a></p>



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



<p>The first aspect of this system is the creating the widget itself. <br><br><strong>The widget we are creating is a main menu style widget that has a vertical list of buttons.</strong><br><br><strong>If you already have a completed widget you can skip to the &#8220;Displaying the Widget&#8221; section.</strong><br><br>Firstly, right click in the content browser and create a new widget blueprint.</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="413" height="293" src="https://couchlearn.com/wp-content/uploads/2021/01/image-52.png" alt="Creating a new widget" class="wp-image-1491" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-52.png 413w, https://couchlearn.com/wp-content/uploads/2021/01/image-52-300x213.png 300w" sizes="(max-width: 413px) 100vw, 413px" /></figure>



<h4 class="wp-block-heading">Creating the Menu Title Text</h4>



<p>The first widget component to add is a text block that is set to the anchor shown below.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="288" height="354" src="https://couchlearn.com/wp-content/uploads/2021/01/image-53.png" alt="Adding a anchored text box" class="wp-image-1494" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-53.png 288w, https://couchlearn.com/wp-content/uploads/2021/01/image-53-244x300.png 244w" sizes="(max-width: 288px) 100vw, 288px" /></figure>



<p>Then, align the text to the top and automatically adjust it&#8217;s horizontal size to the maximum size of the widget.<br><br>This is done by setting the slot position values shown below.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="367" height="283" src="https://couchlearn.com/wp-content/uploads/2021/01/image-54.png" alt="Setting the text properties" class="wp-image-1497" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-54.png 367w, https://couchlearn.com/wp-content/uploads/2021/01/image-54-300x231.png 300w" sizes="(max-width: 367px) 100vw, 367px" /></figure>



<p>The last step with the text is to set the font size to 50 and the justification to center as shown below.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="362" height="460" src="https://couchlearn.com/wp-content/uploads/2021/01/image-55.png" alt="Setting the text font size and margin" class="wp-image-1498" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-55.png 362w, https://couchlearn.com/wp-content/uploads/2021/01/image-55-236x300.png 236w" sizes="(max-width: 362px) 100vw, 362px" /></figure>



<h4 class="wp-block-heading">Creating the Button Container</h4>



<p>We will now create the main container that will store our interactive buttons.<br><br>To do this, firstly create a vertical box widget component.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="695" height="425" src="https://couchlearn.com/wp-content/uploads/2021/01/image-56.png" alt="Creating a vertical box" class="wp-image-1499" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-56.png 695w, https://couchlearn.com/wp-content/uploads/2021/01/image-56-300x183.png 300w" sizes="(max-width: 695px) 100vw, 695px" /></figure>



<p>Then, add as many buttons as you require to the vertical box. <br><br>This stacks the buttons and equally spaces them out in the vertical box.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="689" height="419" src="https://couchlearn.com/wp-content/uploads/2021/01/image-57.png" alt="Adding buttons with text to the vertical box" class="wp-image-1501" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-57.png 689w, https://couchlearn.com/wp-content/uploads/2021/01/image-57-300x182.png 300w" sizes="(max-width: 689px) 100vw, 689px" /></figure>



<p>The final widget hierarchy now looks like this:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="296" height="260" src="https://couchlearn.com/wp-content/uploads/2021/01/image-58.png" alt="Finished widget hierarchy" class="wp-image-1502"/></figure>



<h4 class="wp-block-heading">Adding Functionality</h4>



<p>To make sure our buttons are working correctly in game, we simply add &#8220;On Clicked&#8221; events to each button and print string nodes with the button’s number as the input.<br><br>This will print the value on the screen once interacted with the VR controllers.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="401" height="503" src="https://couchlearn.com/wp-content/uploads/2021/01/image-59.png" alt="Adding events to the buttons to test the vr interaction" class="wp-image-1503" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-59.png 401w, https://couchlearn.com/wp-content/uploads/2021/01/image-59-239x300.png 239w" sizes="(max-width: 401px) 100vw, 401px" /></figure>



<h3 class="wp-block-heading">Displaying the 3D Widget</h3>



<h4 class="wp-block-heading">Creating the Actor</h4>



<p>To place our newly created widget into the world, create a new actor.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="544" height="442" src="https://couchlearn.com/wp-content/uploads/2021/01/image-60.png" alt="Creating a new empty actor" class="wp-image-1535" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-60.png 544w, https://couchlearn.com/wp-content/uploads/2021/01/image-60-300x244.png 300w" sizes="(max-width: 544px) 100vw, 544px" /></figure>



<p>For this guide we named this actor &#8220;VRWorldObject&#8221;.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="701" height="324" src="https://couchlearn.com/wp-content/uploads/2021/01/image-61.png" alt="Newly created actor named VRWorldObject" class="wp-image-1536" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-61.png 701w, https://couchlearn.com/wp-content/uploads/2021/01/image-61-300x139.png 300w" sizes="(max-width: 701px) 100vw, 701px" /></figure>



<h4 class="wp-block-heading">Adding the Widget Component</h4>



<p>To add a widget into this actor, create a new &#8220;Widget&#8221; component.</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://couchlearn.com/wp-content/uploads/2021/01/image-63.png" alt="Adding the widget component" class="wp-image-1538" width="299" height="166"/></figure>



<p>To show the Widget component&#8217;s settings, click on the component in the components menu below the add component button.<br><br>In the widget class drop down box select the widget we created earlier. In this case we selected &#8220;VRUIWidget&#8221;.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="530" height="297" src="https://couchlearn.com/wp-content/uploads/2021/01/image-64.png" alt="Adding the widget class to the widget component of the created actor" class="wp-image-1540" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-64.png 530w, https://couchlearn.com/wp-content/uploads/2021/01/image-64-300x168.png 300w" sizes="(max-width: 530px) 100vw, 530px" /></figure>



<p>Internally the widget is rendered into a texture. To make your widget draw with a high resolution, set the Draw Size X value to 1920 and the Y value to 1080.<br><br>Lower values will still work but will display lower resolution and pixelated widgets in the game world.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="499" height="298" src="https://couchlearn.com/wp-content/uploads/2021/01/image-65.png" alt="Setting the draw size of the drawn widget" class="wp-image-1541" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-65.png 499w, https://couchlearn.com/wp-content/uploads/2021/01/image-65-300x179.png 300w" sizes="(max-width: 499px) 100vw, 499px" /></figure>



<p>Now in the viewport of the blueprint editor you can see your widget rendered.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="697" height="673" src="https://couchlearn.com/wp-content/uploads/2021/01/image-66.png" alt="The vr widget is now displayed in the blueprint editor." class="wp-image-1543" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-66.png 697w, https://couchlearn.com/wp-content/uploads/2021/01/image-66-300x290.png 300w" sizes="(max-width: 697px) 100vw, 697px" /></figure>



<p>Now your widget actor is complete! Drag this actor from the content browser into any level to show the widget in the world.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="567" src="https://couchlearn.com/wp-content/uploads/2021/01/image-68-1024x567.png" alt="The widget is now displayed in the level." class="wp-image-1547" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-68-1024x567.png 1024w, https://couchlearn.com/wp-content/uploads/2021/01/image-68-300x166.png 300w, https://couchlearn.com/wp-content/uploads/2021/01/image-68-768x425.png 768w, https://couchlearn.com/wp-content/uploads/2021/01/image-68.png 1032w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Interacting with the 3D Widget</h3>



<p>By default world space widgets inside of actors cannot be interacted like standard widgets.<br><br>To allow interactions, firstly open the BP_MotionController blueprint.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="795" height="323" src="https://couchlearn.com/wp-content/uploads/2021/01/image-69.png" alt="Opening the BP motion controller blueprint to implement widget interaction" class="wp-image-1548" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-69.png 795w, https://couchlearn.com/wp-content/uploads/2021/01/image-69-300x122.png 300w, https://couchlearn.com/wp-content/uploads/2021/01/image-69-768x312.png 768w" sizes="(max-width: 795px) 100vw, 795px" /></figure>



<p>Inside the BP_MotionController blueprint, add a new &#8220;Widget Interaction&#8221; component to the HandMesh skeletal mesh component.<br><br>This makes sure that the interaction component will follow the movement and the rotation of the VR controllers.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="288" height="227" src="https://couchlearn.com/wp-content/uploads/2021/01/image-70.png" alt="Adding the widget interaction component" class="wp-image-1549"/></figure>



<p>Then, click the Widget Interaction component to show it&#8217;s settings and adjust the interaction distance to however far away you want the players to interact with the widgets.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="343" height="185" src="https://couchlearn.com/wp-content/uploads/2021/01/image-72.png" alt="Adjusting the widget interaction component's interaction distance value" class="wp-image-1551" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-72.png 343w, https://couchlearn.com/wp-content/uploads/2021/01/image-72-300x162.png 300w" sizes="(max-width: 343px) 100vw, 343px" /></figure>



<p>Now in the viewport you can see the widget interaction arrow displaying the interaction distance and the direction it is pointing in. <br><br>This can be adjusted by changing the component&#8217;s location and rotation values.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="768" height="498" src="https://couchlearn.com/wp-content/uploads/2021/01/image-71.png" alt="Visualising the widget interaction component's interaction distance" class="wp-image-1550" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-71.png 768w, https://couchlearn.com/wp-content/uploads/2021/01/image-71-300x195.png 300w" sizes="(max-width: 768px) 100vw, 768px" /></figure>



<p>To show a laser pointer like line where the controller is interacting, simple enable the &#8220;Show Debug&#8221; checkbox in the Debugging section of the WidgetInteraction component.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="419" height="88" src="https://couchlearn.com/wp-content/uploads/2021/04/image-3.png" alt="Enabling the debug view for laser pointer like lines." class="wp-image-1589" srcset="https://couchlearn.com/wp-content/uploads/2021/04/image-3.png 419w, https://couchlearn.com/wp-content/uploads/2021/04/image-3-300x63.png 300w" sizes="(max-width: 419px) 100vw, 419px" /></figure>



<p>Lastly, to differentiate between the two controllers the engine uses the &#8220;Pointer Index&#8221; variable on the widget interaction component.<br><br>In the Invert Scale on hand mesh to create left-hand section of the MotionControllerBP blueprint add a &#8220;Set Pointer Index&#8221; node and set the value to &#8220;1.0&#8221; as shown below.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="897" height="339" src="https://couchlearn.com/wp-content/uploads/2021/04/image-20.png" alt="Setting the pointer index to allow for different hand inputs simultaneously." class="wp-image-1610" srcset="https://couchlearn.com/wp-content/uploads/2021/04/image-20.png 897w, https://couchlearn.com/wp-content/uploads/2021/04/image-20-300x113.png 300w, https://couchlearn.com/wp-content/uploads/2021/04/image-20-768x290.png 768w" sizes="(max-width: 897px) 100vw, 897px" /></figure>



<h4 class="wp-block-heading">Interact with the VR Controllers</h4>



<p>The BP_MotionController blueprint has the interaction enabled but cannot <strong>click or select</strong> any widgets.<br><br>To achieve this, firstly right click in the event graph of the BP_MotionController and create two new custom events named &#8220;TriggerInteract&#8221; and &#8220;TriggerRelease&#8221;.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="173" height="194" src="https://couchlearn.com/wp-content/uploads/2021/04/image-15.png" alt="New custom events" class="wp-image-1605"/></figure>



<p>If you haven&#8217;t used custom events in Unreal Engine 4 <a href="https://couchlearn.com/how-to-use-custom-events-in-unreal-engine-4/">click here to learn how to use custom events in your game.</a></p>



<p>To trigger a click / select event in our Widget Interaction component, right click and get the Widget Interaction reference.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="410" height="410" src="https://couchlearn.com/wp-content/uploads/2021/01/image-76.png" alt="Getting the widget interaction component reference" class="wp-image-1557" srcset="https://couchlearn.com/wp-content/uploads/2021/01/image-76.png 410w, https://couchlearn.com/wp-content/uploads/2021/01/image-76-300x300.png 300w, https://couchlearn.com/wp-content/uploads/2021/01/image-76-150x150.png 150w" sizes="(max-width: 410px) 100vw, 410px" /></figure>



<p>Then, click and drag from the Widget Interaction pin and create a Press Pointer Key function.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="404" height="160" src="https://couchlearn.com/wp-content/uploads/2021/04/image-16.png" alt="Press pointer key function creation" class="wp-image-1606" srcset="https://couchlearn.com/wp-content/uploads/2021/04/image-16.png 404w, https://couchlearn.com/wp-content/uploads/2021/04/image-16-300x119.png 300w" sizes="(max-width: 404px) 100vw, 404px" /></figure>



<p>Change the key to Left Mouse Button to allow the &#8220;TriggerInteract&#8221; event to click and release the left mouse button interaction on the widget.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="499" height="170" src="https://couchlearn.com/wp-content/uploads/2021/04/image-17.png" alt="Assigning the left mouse button key to the press pointer key function" class="wp-image-1607" srcset="https://couchlearn.com/wp-content/uploads/2021/04/image-17.png 499w, https://couchlearn.com/wp-content/uploads/2021/04/image-17-300x102.png 300w" sizes="(max-width: 499px) 100vw, 499px" /></figure>



<p>Repeat this for the &#8220;TriggerRelease&#8221; event but use the Release Pointer Key function instead.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="509" height="349" src="https://couchlearn.com/wp-content/uploads/2021/04/image-18.png" alt="Creating the release pointer key and assigning the left mouse button to the event." class="wp-image-1608" srcset="https://couchlearn.com/wp-content/uploads/2021/04/image-18.png 509w, https://couchlearn.com/wp-content/uploads/2021/04/image-18-300x206.png 300w" sizes="(max-width: 509px) 100vw, 509px" /></figure>



<p>Finally, in the MotionControllerPawn blueprint call our new event from the &#8220;LeftGrab&#8221; and &#8220;RightGrab&#8221; input actions.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="667" height="291" src="https://couchlearn.com/wp-content/uploads/2021/04/image-13.png" alt="Calling the new event on each controller." class="wp-image-1602" srcset="https://couchlearn.com/wp-content/uploads/2021/04/image-13.png 667w, https://couchlearn.com/wp-content/uploads/2021/04/image-13-300x131.png 300w" sizes="(max-width: 667px) 100vw, 667px" /></figure>



<p>The finished input blueprint nodes in the MotionControllerPawn should now look like this.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="687" height="520" src="https://couchlearn.com/wp-content/uploads/2021/04/image-19.png" alt="The final InputAction setup with custom events." class="wp-image-1609" srcset="https://couchlearn.com/wp-content/uploads/2021/04/image-19.png 687w, https://couchlearn.com/wp-content/uploads/2021/04/image-19-300x227.png 300w" sizes="(max-width: 687px) 100vw, 687px" /></figure>



<p>Your basic VR widget interaction system is now complete!</p>



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



<figure class="wp-block-video"><video autoplay loop muted src="https://couchlearn.com/wp-content/uploads/2022/10/vrwidgetinteraction.webm" playsinline></video></figure>



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



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



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



<p>Now your project has basic VR compatible widget interaction!<br><br>We are planning to create many more VR guides over this year. If you have a specific topic you would like a guide for, feel free to <a href="https://couchlearn.com/contact-us/">contact us.</a><br><br>If you are interested in more Widget Interaction and 3D widget features in Unreal Engine 4, here are some links for further reading:<br><br><a href="https://docs.unrealengine.com/en-US/InteractiveExperiences/UMG/HowTo/InWorldWidgetInteraction/index.html">Click here to read the 3D widget Unreal Engine 4 documentation.</a><br><br><a href="https://docs.unrealengine.com/en-US/InteractiveExperiences/UMG/UserGuide/WidgetInteraction/index.html">Click here to read the Widget Interaction Unreal Engine 4 documentation.</a></p>
<p>The post <a href="https://couchlearn.com/how-to-make-vr-interactable-ui-widgets-in-unreal-engine-4/">How to make VR Interactable UI Widgets in Unreal Engine 4</a> appeared first on <a href="https://couchlearn.com">Couch Learn</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://couchlearn.com/how-to-make-vr-interactable-ui-widgets-in-unreal-engine-4/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		<enclosure url="https://couchlearn.com/wp-content/uploads/2022/10/vrwidgetinteraction.webm" length="0" type="video/webm" />

			</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-11 04:36:11 by W3 Total Cache
-->