<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Move 3dMarker depending on camera look]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=415&amp;type=atom" />
	<updated>2017-02-13T12:42:27Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=415</id>
		<entry>
			<title type="html"><![CDATA[Re: Move 3dMarker depending on camera look]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=1813#p1813" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Alex Vertax wrote:</cite><blockquote><p>Hello.</p><p>The modified script is attached.</p><p>1. Move «ThirdPersonUserControl» script outside of «Standard Assets» or move «Online Maps» folder into «Standard Assets».<br />2. Wrap «ThirdPersonController» in a new empty GameObject, and create a prefab from the outer GameObject.<br />3. Use the new prefab for 3D marker.</p></blockquote></div><p>Thanks, Alex! Works perfectly<br /></p><div class="codebox"><pre><code>...
  api.GetTilePosition(out px, out py);
...

 var cameraLook = Vector3.Scale(m_Cam.forward, new Vector3(-1, 0, -1)).normalized;
                m_Move = h * cameraLook + v * m_Cam.right;
                px -= m_Move.x * moveScale;
                py += m_Move.z * moveScale;
                double lng, lat;
                api.projection.TileToCoordinates(px, py, api.zoom, out lng, out lat);
                api.SetPosition(lng, lat);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DolceVita]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=376</uri>
			</author>
			<updated>2017-02-13T12:42:27Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=1813#p1813</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Move 3dMarker depending on camera look]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=1810#p1810" />
			<content type="html"><![CDATA[<p>Hello.</p><p>The modified script is attached.</p><p>1. Move «ThirdPersonUserControl» script outside of «Standard Assets» or move «Online Maps» folder into «Standard Assets».<br />2. Wrap «ThirdPersonController» in a new empty GameObject, and create a prefab from the outer GameObject.<br />3. Use the new prefab for 3D marker.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-02-13T01:37:45Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=1810#p1810</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Move 3dMarker depending on camera look]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=1806#p1806" />
			<content type="html"><![CDATA[<p>Hi,</p><p>Frankly to say, I am new in Unity3d (hovewer skilled in C#).<br />I have a 3dmap with buildings etc. I placed a 3dmarker (which is basicly a default unity3d thirdPersonController).</p><p>I have the script to control my 3dMarker:<br /></p><div class="codebox"><pre><code>    private void FixedUpdate()
    {
        OnlineMaps api = OnlineMaps.instance;

        float h = CrossPlatformInputManager.GetAxis(&quot;Horizontal&quot;);
        float v = CrossPlatformInputManager.GetAxis(&quot;Vertical&quot;);

       
        m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized;
        var position = v * m_CamForward + h * m_Cam.right;
        if (position.magnitude &gt; 1f) position.Normalize();
        //probably I need to do something here to change h and v depending on the camera angle

        px += h / 100000;
        py += v / 100000;
        api.SetPosition(px, py);
}</code></pre></div><p>So right now my player move in 4 directions. However, if I try to change camera look (with mouse right click), I want my character&nbsp; move forward concidering new &quot;north&quot;.</p><p>Could you please give a clue how to do this? Thank you.</p>]]></content>
			<author>
				<name><![CDATA[DolceVita]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=376</uri>
			</author>
			<updated>2017-02-10T18:26:20Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=1806#p1806</id>
		</entry>
</feed>
