<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Strange interaction with phone gyroscope and NavMeshAgent]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1392&amp;type=atom" />
	<updated>2019-11-13T15:19:07Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=1392</id>
		<entry>
			<title type="html"><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5757#p5757" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[fedor]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1102</uri>
			</author>
			<updated>2019-11-13T15:19:07Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5757#p5757</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5752#p5752" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2019-11-13T13:07:51Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5752#p5752</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5751#p5751" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[fedor]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1102</uri>
			</author>
			<updated>2019-11-13T12:32:34Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5751#p5751</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5750#p5750" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2019-11-13T12:11:17Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5750#p5750</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5749#p5749" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[fedor]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1102</uri>
			</author>
			<updated>2019-11-13T12:04:55Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5749#p5749</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5743#p5743" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2019-11-11T10:22:39Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5743#p5743</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5742#p5742" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[fedor]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1102</uri>
			</author>
			<updated>2019-11-11T07:08:16Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5742#p5742</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5739#p5739" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2019-11-08T19:23:46Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5739#p5739</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5737#p5737" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[fedor]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1102</uri>
			</author>
			<updated>2019-11-08T11:55:36Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5737#p5737</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5730#p5730" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2019-11-06T21:55:18Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5730#p5730</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Strange interaction with phone gyroscope and NavMeshAgent]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=5728#p5728" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[fedor]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1102</uri>
			</author>
			<updated>2019-11-06T13:56:32Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=5728#p5728</id>
		</entry>
</feed>
