title: Unity 5 c# Navigation
body: <p>My problem is that my  </p>
  
  <pre><code>var tempTarget RtsManager.Current.ScreenPointToMapPosition(Input.mousePosition);
  </code></pre>
  
  <p>get value null for some reason even that i told it to get the value on mouseclick</p>
  
  <p>i tried to see why it doesnt get a value but cant seem to figured out the problem</p>
  
  <pre><code>public class RtsManager : MonoBehaviour
  {
  
      public static RtsManager Current = null;
  
      public List&lt;PlayerSetupDifinition&gt; Players = new List&lt;PlayerSetupDifinition&gt;();
  
      public TerrainCollider MapCollider;
  
      public Vector3? ScreenPointToMapPosition(Vector2 point)
  
      {
          var ray = Camera.main.ScreenPointToRay(point);
          RaycastHit hit;
          if (!MapCollider.Raycast(ray, out hit, Mathf.Infinity))
              return null;
  
          return hit.point;
      }
  
      // Use this for initialization
      void Start()
      {
          Current = null;
  
          foreach (var p in Players)
          {
              foreach (var u in p.StartingUnits)
              {
                  var go = (GameObject)GameObject.Instantiate(u, p.Location.position, p.Location.rotation);
  
                  if (!p.isAi)
                  { go.AddComponent&lt;RightClickNavigation&gt;(); }
  
  
  
              }
          }
      }
  
      // Update is called once per frame
      void Update()
      {
  
      }
  }
  
  
  public class RightClickNavigation : Interaction {
  
      public float RelaxDistance = 5;
  
      private NavMeshAgent agent;
      private Vector3 target = Vector3.zero;
      private bool selected = false;
      private bool isActive = false;
  
      public override void Deselect()
      {
          selected = false;
      }
  
      public override void Select()
      {
          selected = true;
      }
  
      public void SendToTarget()
      {
          agent.SetDestination(target);
          agent.Resume();
          isActive = true;
      }
  
      void Start () {
          agent = GetComponent&lt;NavMeshAgent&gt;();
      }
  
      // Update is called once per frame
      void Update () {
          if(selected &amp;&amp; Input.GetMouseButtonDown (1))
          {
  
  
              var tempTarget = RtsManager.Current.ScreenPointToMapPosition(Input.mousePosition);
  
              if (tempTarget.HasValue)
              {
                  target = tempTarget.Value;
                  SendToTarget();
              }
  
          }
  
          if(isActive &amp;&amp; Vector3.Distance(target, transform.position) &lt; RelaxDistance)
          {
              agent.Stop();
              isActive = false;
          }
  
      }
  }
  </code></pre>