Navmesh Agent Not placed on mesh?

Hi gang, I have Instantiated a navmesh Agent on a cube, both the Spawnpoint and the Baked Navmesh plane are at 0,0,0 so it should be spawning on the Navmeshplane but I’m getting the
Notp laced on navmesh Error any way to fix this?
“GetRemainingDistance” can only be called on an active agent that has been placed on a NavMesh.
Everything is setup correctly.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using Photon;
public class PlayerMove : Photon.MonoBehaviour {

	public float ShootDistance = 10;
	public PlayerShooting PlayerShoot;
	public NavMeshAgent Agent;
	private Ray ShootingRay;
	private RaycastHit shootHit;

	public bool TeamOne;
	public bool TeamTwo;
	private bool enemyClicked;

	// Use this for initialization
	void Start () {
		if (photonView.isMine == true) {
			gameObject.tag = "MyPlayer";
			Agent = gameObject.GetComponent<NavMeshAgent> ();
			Agent.GetComponent<NavMeshAgent> ();

	// Update is called once per frame
	void Update () {
		Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
		RaycastHit hit;
		if (Input.GetButtonDown ("Fire2")) {
			if (Physics.Raycast (ray, out hit, 10000)) {

				if (TeamOne == true) {
					if (hit.collider.CompareTag ("TeamTwo")) {
						enemyClicked = true;
						Agent.Resume ();


				if (TeamTwo == true) {
					if (hit.collider.CompareTag ("TeamOne")) {
						enemyClicked = true;
			} else {
				enemyClicked = false;
				Agent.destination = hit.point;
				Agent.Resume ();

		if (Agent.remainingDistance <= Agent.stoppingDistance) {
			Agent.Stop ();
		} else {
			Agent.Resume ();

		if (enemyClicked == true && Agent.remainingDistance < ShootDistance) {
			PlayerShoot.Shooting = true;
		} else {
			PlayerShoot.Shooting = false;



this error usually appears when nav mesh agent is not placed on navmesh area.
there are some mistakes that people do often when dealing with navmesh agents.
i will try to sort some of them here, I hope this helps.

first of all, placing navmesh agent below navmesh level, this usually throws this error. to avoid this, place your navmesh agent lite bit higher than navmesh (just lite bit not too much nor same level)

second, changing game objects transform after initializing, if a game objects position changes via code navmesh agent may stuck old position, thus can cause this kind of error. to solve this I Suggest using NavMeshAgent.Warp instead of changing game objects transofm.position.

another cause of this error is , sometimes navmesh data can be corrupted (after updating unity for example) if this is a problem solution is re-baking nav mesh usually.

please check this steps and inform us if you get this error again. if your problem isn’t one of the mistakes I pointed here, we will help you to investigate deeper.

I found a solution by adding a tag to the floor called “floor”, then adding this to the bottom of the script:

 public void OnTriggerEnter(Collider other)
        if ((other.tag == "floor") && (isonfloor == false))
            agent.enabled = false;
            agent.enabled = true;

It seems to reset them if they have left the ground (like when you fly-kick them).

The error “XXX can only be called on an active agent that has been placed on a NavMesh” occurred even if your setting are 100% correct but somehow your baked navMesh was gone.
What you have to do is bake that mesh again, cheers!