<?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>input &#8211; INCD021</title>
	<atom:link href="https://incd021.com/tag/input/feed/" rel="self" type="application/rss+xml" />
	<link>https://incd021.com</link>
	<description>Programming, thoughts, life  and art.</description>
	<lastBuildDate>Tue, 10 Sep 2013 18:52:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>Unity touch input</title>
		<link>https://incd021.com/2013/09/10/unity-touch-input/</link>
					<comments>https://incd021.com/2013/09/10/unity-touch-input/#comments</comments>
		
		<dc:creator><![CDATA[INC $D021]]></dc:creator>
		<pubDate>Tue, 10 Sep 2013 18:52:07 +0000</pubDate>
				<category><![CDATA[Game]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Touch]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Unity Touch Input]]></category>
		<guid isPermaLink="false">http://incd021.com/?p=402</guid>

					<description><![CDATA[My first encounter with Unity touch input didn&#8217;t go as I wanted it to.. After some failed attempt and a test scene in Unity, it did started to make sense.....]]></description>
										<content:encoded><![CDATA[<p>My first encounter with Unity touch input didn&#8217;t go as I wanted it to.. After some failed attempt and a test scene in Unity, it did started to make sense. And finding out that touch has phases and FingerId&#8217;s helped a lot. <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> So here&#8217;s my take on a controller and firing script for my current project.</p>
<pre class="brush: csharp; gutter: true">private shieldFingerId = -1;

...
// If nothing is touched, the shield controller has been released
// Know I should test for the shieldFingerId to be released, but this works for my purpose.
if (Input.touchCount == 0)
{
	shieldFingerId = -1;
}

foreach (Touch touch in Input.touches)
{
	// Fire
	if(touch.phase == TouchPhase.Began &amp;&amp; !withinShieldController)
	{
		Fire();
	}

	// &quot;Grap&quot; shield
	if (touch.phase == TouchPhase.Began &amp;&amp; withinShieldController)
	{
		shieldFingerId = touch.fingerId;
		UpdateSheldAngle(touch.position);
	}

	// Move shield
	if (touch.phase == TouchPhase.Moved &amp;&amp; touch.fingerId == shieldFingerId)
	{
		UpdateSheldAngle(touch.position);
	}
}</pre>
<p>As you can see, when I got hold of the information about touch.phase and .fingerId, everything turned out to be very simple indeed.</p>
<p>I found the Unity Script Reference pages to be very limited on the subject of touch input, e.g. information about touch.fingerId only says &#8220;The unique index for touch.&#8221; no examples, or explanation. But by asking Google, and searching the Unity forums, great resource I might add, it finally made sense. <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Working with touch has forced me to use my LG E975 mobile for testing, which is a slow process. :/ I guess I have to figure out how to make Unity Remote work with my phone. If not, development is going to take forever!</p>
<p>Hope the above code makes sense? Now go make games! <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>&#8211; Henning</p>
]]></content:encoded>
					
					<wfw:commentRss>https://incd021.com/2013/09/10/unity-touch-input/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Page Caching using Disk: Enhanced 

Served from: incd021.com @ 2025-05-18 03:11:55 by W3 Total Cache
-->