<?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>ue4 line trace Archives - Couch Learn</title>
	<atom:link href="https://couchlearn.com/tag/ue4-line-trace/feed/" rel="self" type="application/rss+xml" />
	<link>https://couchlearn.com/tag/ue4-line-trace/</link>
	<description>Detailed Game Programming Tutorials</description>
	<lastBuildDate>Sat, 25 Jan 2025 17:33:01 +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>ue4 line trace Archives - Couch Learn</title>
	<link>https://couchlearn.com/tag/ue4-line-trace/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Basic First Person Line Trace in Unreal Engine 4</title>
		<link>https://couchlearn.com/basic-first-person-line-trace-in-unreal-engine-4/</link>
					<comments>https://couchlearn.com/basic-first-person-line-trace-in-unreal-engine-4/#respond</comments>
		
		<dc:creator><![CDATA[Matt]]></dc:creator>
		<pubDate>Wed, 05 Aug 2020 13:06:16 +0000</pubDate>
				<category><![CDATA[Medium Difficulty]]></category>
		<category><![CDATA[UE4 Basics]]></category>
		<category><![CDATA[Unreal Basics]]></category>
		<category><![CDATA[Unreal Engine]]></category>
		<category><![CDATA[line trace]]></category>
		<category><![CDATA[ue4]]></category>
		<category><![CDATA[ue4 basics]]></category>
		<category><![CDATA[ue4 first person]]></category>
		<category><![CDATA[ue4 first person line trace]]></category>
		<category><![CDATA[ue4 fps]]></category>
		<category><![CDATA[ue4 line trace]]></category>
		<category><![CDATA[ue4 raycast]]></category>
		<category><![CDATA[ue4 trace]]></category>
		<category><![CDATA[unreal engine]]></category>
		<category><![CDATA[unreal engine 4]]></category>
		<category><![CDATA[unreal engine fps]]></category>
		<guid isPermaLink="false">https://couchlearn.com/?p=1215</guid>

					<description><![CDATA[<p>In this guide we will explain what a Line Trace is an how to create a Basic First Person Line Trace in Unreal Engine 4 <a class="mh-excerpt-more" href="https://couchlearn.com/basic-first-person-line-trace-in-unreal-engine-4/" title="Basic First Person Line Trace in Unreal Engine 4">[...]</a></p>
<p>The post <a href="https://couchlearn.com/basic-first-person-line-trace-in-unreal-engine-4/">Basic First Person Line Trace in Unreal Engine 4</a> appeared first on <a href="https://couchlearn.com">Couch Learn</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this guide we will explain what a Line Trace is an how to create a Basic First Person Line Trace in Unreal Engine 4<br><br><strong>This guide builds upon the First Person Example template built into Unreal Engine 4.</strong></p>



<h3 class="wp-block-heading">How a Line Trace Works</h3>



<p>A line trace is a way to check if an object is intersecting a line. The hit data is then broken down access more information such as location of hit, normal of hit. the actor that was hit and distance from hit.</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="719" height="480" src="https://couchlearn.com/wp-content/uploads/2020/08/image-22.png" alt="An example of a line trace hitting a first person character" class="wp-image-1229" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-22.png 719w, https://couchlearn.com/wp-content/uploads/2020/08/image-22-300x200.png 300w" sizes="(max-width: 719px) 100vw, 719px" /></figure>



<h3 class="wp-block-heading">Different Types of Line Traces</h3>



<p>&#8220;Line Trace for Objects&#8221; checks an intersection with a specific collision object type. (WorldStatic, WorldDynamic, Pawn, Ragdoll, PhysicsActor, etc)</p>



<figure class="wp-block-image size-large"><img decoding="async" width="381" height="465" src="https://couchlearn.com/wp-content/uploads/2020/08/image-23.png" alt="Calculate a line trace by collision object type" class="wp-image-1230" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-23.png 381w, https://couchlearn.com/wp-content/uploads/2020/08/image-23-246x300.png 246w" sizes="(max-width: 381px) 100vw, 381px" /></figure>



<p>&#8220;Line Trace by Channel&#8221; checks for an intersection with a specific line trace collision channel. (Visibility and Camera are the default options)</p>



<figure class="wp-block-image size-large"><img decoding="async" width="350" height="383" src="https://couchlearn.com/wp-content/uploads/2020/08/image-24.png" alt="Calculate a line trace by trace channel" class="wp-image-1231" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-24.png 350w, https://couchlearn.com/wp-content/uploads/2020/08/image-24-274x300.png 274w" sizes="(max-width: 350px) 100vw, 350px" /></figure>



<p>&#8220;Line Trace by Channel&#8221; checks for an intersection with a specific collision profile by name. (These can be viewed and created in the collision tab of the project settings)</p>



<figure class="wp-block-image size-large"><img decoding="async" width="349" height="353" src="https://couchlearn.com/wp-content/uploads/2020/08/image-25.png" alt="Calculate a line trace by collision profile" class="wp-image-1232" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-25.png 349w, https://couchlearn.com/wp-content/uploads/2020/08/image-25-297x300.png 297w" sizes="(max-width: 349px) 100vw, 349px" /></figure>



<h3 class="wp-block-heading">How to Calculate the First Person Line Trace</h3>



<p>All line traces have the same basic setup. The nodes below setup the vector maths required to check for any collisions wherever the camera is located and facing.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="599" height="332" src="https://couchlearn.com/wp-content/uploads/2020/08/image-17.png" alt="The universal setup for all first person line traces" class="wp-image-1222" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-17.png 599w, https://couchlearn.com/wp-content/uploads/2020/08/image-17-300x166.png 300w" sizes="(max-width: 599px) 100vw, 599px" /></figure>



<h4 class="wp-block-heading">Breaking down the Maths</h4>



<p>Firstly you use the FirstPersonCamera variable connected to the GetWorldLocation node to begin the line trace from your character&#8217;s camera position.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="227" height="129" src="https://couchlearn.com/wp-content/uploads/2020/08/image-18.png" alt="Getting the world location of the first person camera" class="wp-image-1223"/></figure>



<p>Next using the Get Controller node, get the controller rotation from the Get Control Rotation node. This will get the rotation of your camera and even works multiplayer games.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="232" height="164" src="https://couchlearn.com/wp-content/uploads/2020/08/image-19.png" alt="Getting the control rotation for multiplayer compatibility" class="wp-image-1224"/></figure>



<p>Afterwards connect the Get Control Rotation node to the Get Forward Vector node. This will get the direction your camera is facing of your camera.<br><br>Multiply this Get Forward Vector value by 5000 (Multiple Vector by Float) to get a point in space from 0,0,0 that is 5000 units away facing the direction of the camera.<br><em>(This is the distance away from the camera to check fora collision. Change this to whichever distance you need for your project).</em><br><br>Finally add the Get World Location return value of your First Person Camera to the multiplied value. This gets the point in 3D space that you are looking at 5000 units in front of your camera.</p>



<h3 class="wp-block-heading">Accessing the Hit Data</h3>



<p>Connecting the return value to a branch only allows successful line traces to be accessed. Not including this branch will cause lots of console errors when accessing the hit result data.<br><br>To access this data click and drag from the Out Hit value and create a Break Hit Result node.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="729" height="489" src="https://couchlearn.com/wp-content/uploads/2020/08/image-20.png" alt="Accessing the data from a line trace" class="wp-image-1226" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-20.png 729w, https://couchlearn.com/wp-content/uploads/2020/08/image-20-300x201.png 300w" sizes="(max-width: 729px) 100vw, 729px" /></figure>



<h3 class="wp-block-heading">The Complete First Person Line Trace</h3>



<p>This is one example of a complete first person line trace. <br><br>To use this system simply connect the execution pins to any event you want e.g. Event Tick or an event</p>



<figure class="wp-block-image size-large"><img decoding="async" width="967" height="376" src="https://couchlearn.com/wp-content/uploads/2020/08/image-16.png" alt="An example of a complete first person line trace" class="wp-image-1221" srcset="https://couchlearn.com/wp-content/uploads/2020/08/image-16.png 967w, https://couchlearn.com/wp-content/uploads/2020/08/image-16-300x117.png 300w, https://couchlearn.com/wp-content/uploads/2020/08/image-16-768x299.png 768w" sizes="(max-width: 967px) 100vw, 967px" /></figure>



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



<p>Your project now is setup to use a basic First Person Line Trace in Unreal Engine 4!<br><br>Your project can now detect when objects are in front of the camera. Many use this system for weapons, interacting with objects such as doors, pickups and much more!<br><br><strong>Further Reading</strong>:<br><br>Combine this line trace system with our easy AI movement guide to create computer controlled character that can interact with objects! <a href="https://couchlearn.com/easy-ai-movement-in-unreal-engine-4/">https://couchlearn.com/easy-ai-movement-in-unreal-engine-4/</a><br><br>Unreal Engine&#8217;s documentation on single line traces: <a href="https://docs.unrealengine.com/en-US/Engine/Physics/Tracing/HowTo/SingleLineTraceByChannel/index.html">https://docs.unrealengine.com/en-US/Engine/Physics/Tracing/HowTo/SingleLineTraceByChannel/index.html</a><br><br>Unreal Engine&#8217;s full documentation on traces: <a href="https://docs.unrealengine.com/en-US/Engine/Physics/Tracing/Overview/index.html">https://docs.unrealengine.com/en-US/Engine/Physics/Tracing/Overview/index.html</a></p>
<p>The post <a href="https://couchlearn.com/basic-first-person-line-trace-in-unreal-engine-4/">Basic First Person Line Trace in Unreal Engine 4</a> appeared first on <a href="https://couchlearn.com">Couch Learn</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://couchlearn.com/basic-first-person-line-trace-in-unreal-engine-4/feed/</wfw:commentRss>
			<slash:comments>0</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-16 04:24:25 by W3 Total Cache
-->