<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Strange interaction with phone gyroscope and NavMeshAgent]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=1392</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1392&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Strange interaction with phone gyroscope and NavMeshAgent.]]></description>
		<lastBuildDate>Wed, 13 Nov 2019 15:19:07 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5757#p5757</link>
			<description><![CDATA[<p>Thank you very much, thats what I needed indeed! It definitely helps but only after some time has passed - my guess that loading tiles also calls map.Redraw(). And when all tiles has finished loading - everything is fine!</p><p>Thanks again <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (fedor)]]></author>
			<pubDate>Wed, 13 Nov 2019 15:19:07 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5757#p5757</guid>
		</item>
		<item>
			<title><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5752#p5752</link>
			<description><![CDATA[<p>Most likely, the compass causes the map to be redrawn, because on the device the values of this sensor very often jitter.<br />Online Maps smooths out this jitter, and you may not see it.</p><p>You have two ways:<br />1. Just when you want to start moving GameObject in the scene, turn off the compass (Input.compass.enabled = false). <br />I have not tried this, but theoretically this should work.<br />2. Modify the script OnlineMapsLocationServiceBase (line 505), and comment out or delete the map redrawing by compass.<br />Result:<br /></p><div class="codebox"><pre><code>if (positionChanged/* || compassChanged*/) map.Redraw();</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 13 Nov 2019 13:07:51 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5752#p5752</guid>
		</item>
		<item>
			<title><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5751#p5751</link>
			<description><![CDATA[<p>Thank you, that would work and whats I do. BUT as I stated before OnLocationChanged is NOT called( I am sure of it because I listen to OnLocationChanged and have counter to increase each time this event happens) because movement of 5mm is too small for GPS to update it&#039;s location but map still updates so marker position resets. I do solve this problem by updating the marker’s geographic position based on Unity World Position on each frame though I don&#039;t like it because on my opinion it&#039;s too much calculations and idealogically is not correct. So I lost my mind trying to figure out why small handshake affects position of marker. </p><p>At this point I am thinking on giving up trying to figure out reason of that/</p>]]></description>
			<author><![CDATA[null@example.com (fedor)]]></author>
			<pubDate>Wed, 13 Nov 2019 12:32:34 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5751#p5751</guid>
		</item>
		<item>
			<title><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5750#p5750</link>
			<description><![CDATA[<p>Ah, got it.<br />1. Listen to OnLocationChanged.<br />2. Calculate the distance between the previous location and the new location (OnlineMapsUtils.DistanceBetweenPoints).<br />3. If the distance is less than 20 meters, ignore this event.<br />4. If the distance is more than 20 meters, do what you want from this update.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 13 Nov 2019 12:11:17 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5750#p5750</guid>
		</item>
		<item>
			<title><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5749#p5749</link>
			<description><![CDATA[<p>Nooo, seems like you don&#039;t get my question. I will try again: It already happens and I DON&#039;T want it to happen!!! I need for your map to update every 20 real world meters BUT it updates marker position every 5 realworld millimeters and I don&#039;t know why! Simple handshake denies movement of the marker!</p>]]></description>
			<author><![CDATA[null@example.com (fedor)]]></author>
			<pubDate>Wed, 13 Nov 2019 12:04:55 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5749#p5749</guid>
		</item>
		<item>
			<title><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5743#p5743</link>
			<description><![CDATA[<p>Unfortunately, I do not know what to recommend to you.<br />You can try to use all sensors (GPS + gyro + compass + accelerometer).<br />Online Maps does not force you to use the Online Maps Location Service.<br />You can use any custom solution.</p><p>Actually, if your experiment will be successful, you can sell it as an asset.<br />I think many developers will be interested in increasing accuracy.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 11 Nov 2019 10:22:39 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5743#p5743</guid>
		</item>
		<item>
			<title><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5742#p5742</link>
			<description><![CDATA[<p>Oh, thank you, that&#039;s definitely useful info, but not the thing I was wondering about. My bad, I guess I&#039;ve stated my problem incorrectly. I will try to rephrase it:<br />I only need to move phone less than 1cm or change it&#039;s angle like by 2 degrees and snapping occurs. GPS only updates every 10-15 meters ( and OnLocationChanged is not called ) thus reason of snapping is gyroscope and/or compass</p>]]></description>
			<author><![CDATA[null@example.com (fedor)]]></author>
			<pubDate>Mon, 11 Nov 2019 07:08:16 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5742#p5742</guid>
		</item>
		<item>
			<title><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5739#p5739</link>
			<description><![CDATA[<p>Gyroscope, GPS and compass do not interact with each other.<br />These are different features.</p><p>GPS (OM Location Service) looks at changes in LocationInfo, and if something has changed, calls OnLocationChanged.<br /><a href="https://docs.unity3d.com/ScriptReference/LocationInfo.html">https://docs.unity3d.com/ScriptReferenc … nInfo.html</a><br />OnLocationInited is called when the first values appear in LocationInfo.</p><p>Civilian GPS has a rather low accuracy (compared to military devices), and depending on the device and the place where you are (in the city or in the open space) it can have a real accuracy of 5-30 meters.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 08 Nov 2019 19:23:46 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5739#p5739</guid>
		</item>
		<item>
			<title><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5737#p5737</link>
			<description><![CDATA[<p>Thank you for your response. Can you please clarify how gyroscope and GPS interact with each other and what really causes map updates. I do already use OnLocationInited and OnLocationChanged and these events are not called at all if I move less than 10-15 meters.</p>]]></description>
			<author><![CDATA[null@example.com (fedor)]]></author>
			<pubDate>Fri, 08 Nov 2019 11:55:36 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5737#p5737</guid>
		</item>
		<item>
			<title><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5730#p5730</link>
			<description><![CDATA[<p>Hello.</p><p>This is because you are using NavMeshAgent on the marker that is created by Online Maps Location Service.<br />With every GPS update, Online Maps Location Service updates the marker’s geographic position (reset your changes).<br />With every map update, Online Maps resets your Unity World Position changes, and sets the marker to a position based on geographic coordinates.<br />The map is not updated every frame. Only if something important has changed or you invoked a redraw.</p><p>So here are a few things to make this work correctly:<br />1. Create a marker using Online Maps API.<br />2. When moving NavMeshAgent, update the marker’s geographic position based on Unity World Position.<br />3. Listen to OnLocationInited and OnLocationChanged to process GPS changes (if necessary).<br /><a href="http://infinity-code.com/doxygen/online-maps/classOnlineMapsLocationServiceBase.html#a48763b6f3f12f8065a0a4679479dbafe">http://infinity-code.com/doxygen/online … 79479dbafe</a></p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 06 Nov 2019 21:55:18 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5730#p5730</guid>
		</item>
		<item>
			<title><![CDATA[Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5728#p5728</link>
			<description><![CDATA[<p>Hi. I have one interesting thing happening and looks like Online Maps asset is a reason of this. </p><p>Whats happening:</p><p>When I move marker in Update() with : </p><div class="codebox"><pre><code> navAgent.Move(moveDirection * moveSpeed); </code></pre></div><p> it works perfectly fine on PC, but when it comes to mobile devices - it does not work correctly: marker moves some distance then if I change phone physical position (tilt a little or lift up/move down) marker instantly snaps back to it&#039;s starting point.</p><p>Why do I think that it is because of OnlineMaps? Because if I add following lines: </p><div class="codebox"><pre><code> Vector2 playerGeoPosition = OnlineMapsTileSetControl.instance.GetCoordsByWorldPosition(player.transform.position);
        playerMarker.position = playerGeoPosition; </code></pre></div><p>marker snaps not to the starting position but to the position that was set by this code. </p><p>I do understand why it might snap it&#039;s position but why does it snap each time phone gyroscope values change(If I get it right)?</p><p>P.S. Don&#039;t know why but I&#039;ve attached screenshot of Map and it&#039;s components.</p>]]></description>
			<author><![CDATA[null@example.com (fedor)]]></author>
			<pubDate>Wed, 06 Nov 2019 13:56:32 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5728#p5728</guid>
		</item>
	</channel>
</rss>
