Esempio n. 1
0
	// Use this for initialization
	void Start () {
		GameObject playa = GameObject.FindGameObjectWithTag ("Player");
		pl = playa.GetComponent<Player>();
        anim = GetComponent<Animator>();
        doorObstacle = GetComponent<NavMeshObstacle>();
        col = GetComponent<BoxCollider>();
	}
Esempio n. 2
0
	protected override void Start()
	{
		numInteractuablesEnTransito = 0;

		//Carga los datos del directorio predeterminado o del de guardado si hay datos guardados
		if (System.IO.File.Exists(Manager.rutaInterDatosGuardados + ID.ToString()  + ".xml"))
		{
			datos = ObjetoDatos.LoadInterDatos(Manager.rutaInterDatosGuardados + ID.ToString()  + ".xml");
		}
		else
		{
			datos = ObjetoDatos.LoadInterDatos(Manager.rutaInterDatos + ID.ToString()  + ".xml");
		}

		//Ejecuta el metodo del padre
		base.Start();

		obstacle = GetComponent<NavMeshObstacle>();

		//Establece el nombre del interactuable
		SetNombre(datos.DevuelveNombreActual());

		if(datos.DevuelveIDTransporte() != -1)
			CrearTransporte(datos.DevuelveIDTransporte());
	}
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        if (Input.GetMouseButtonDown (0))
        {
            Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);

            if (Physics.Raycast (ray, out hit, 300.0F)&& hit.transform.CompareTag ("obstacle"))
            {
                obs = hit.collider.gameObject.GetComponent<NavMeshObstacle> ();
                print (obs);
            }

        }

        print (obs);
        if (obs != null)
        {
            float amtToMoveX = Input.GetAxisRaw("Vertical") * PlayerSpeed * Time.deltaTime;

            obs.transform.Translate(Vector3.right * amtToMoveX);
            float amtToMoveZ = Input.GetAxisRaw("Horizontal") * PlayerSpeed * Time.deltaTime;

            obs.transform.Translate(Vector3.forward * -amtToMoveZ);
        }
    }
Esempio n. 4
0
    void Awake()
    {
        agent = GetComponent<NavMeshAgent>();
        obstacle = GetComponent<NavMeshObstacle>();
        m_Animation = GetComponentInChildren<Animation>();
        enemyAttack = GetComponent<EnemyAttack>();
        stats = GetComponent<UnitStats>();
        m_AudioSource = GetComponent<AudioSource>();
        baseAttackSpeedCache = timeBetweenAttacks;

        switch (unitType)
        {
            case EnemyTypes.Minion:
                selectedAction = "Punch";
                break;

            case EnemyTypes.Brute:
                selectedAction = "Slam";
                break;

            case EnemyTypes.Evoker:
                selectedAction = "Shoot";
                break;

            case EnemyTypes.Bob:
                selectedAction = "Explode";
                break;

            default:
                break;
        }
    }
 void Start()
 {
     if (_bull != null) {
         _Charge = _bull.GetComponent<BullBehaviour> ();
     }
         _MeshObstakels  = GetComponent<NavMeshObstacle> ();
 }
 static public int constructor(IntPtr l)
 {
     UnityEngine.NavMeshObstacle o;
     o = new UnityEngine.NavMeshObstacle();
     pushObject(l, o);
     return(1);
 }
Esempio n. 7
0
	void Start () 
	{
		waypoints = GameObject.Find("Hound waypoints");
		agent = proxy.GetComponent<NavMeshAgent>();
		obstacle = proxy.GetComponent<NavMeshObstacle>();
		anim = model.GetComponent<Animator>();
		target = waypoints.transform.GetChild(2);
	}
 static public int set_velocity(IntPtr l)
 {
     UnityEngine.NavMeshObstacle o = (UnityEngine.NavMeshObstacle)checkSelf(l);
     UnityEngine.Vector3         v;
     checkType(l, 2, out v);
     o.velocity = v;
     return(0);
 }
Esempio n. 9
0
 // Use this for initialization
 void Start()
 {
     _navMeshObstacle = GetComponent<NavMeshObstacle>();
     _navMeshObstacle.enabled = false;
     var anim = GetComponent<Animation>();
     anim["Up Down"].wrapMode = WrapMode.Once;
     anim.Play("Up Down");
 }
Esempio n. 10
0
 // Use this for initialization
 void Start()
 {
     startPos = new Vector3 (startX, startY, startZ);
     endPos = new Vector3 (endX, endY, endZ);
     transform.position = startPos;
     travelState = 0;
     nav = GetComponent<NavMeshObstacle> ();
 }
    static public int set_carvingMoveThreshold(IntPtr l)
    {
        UnityEngine.NavMeshObstacle o = (UnityEngine.NavMeshObstacle)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.carvingMoveThreshold = v;
        return(0);
    }
    static public int set_radius(IntPtr l)
    {
        UnityEngine.NavMeshObstacle o = (UnityEngine.NavMeshObstacle)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.radius = v;
        return(0);
    }
    static public int set_carving(IntPtr l)
    {
        UnityEngine.NavMeshObstacle o = (UnityEngine.NavMeshObstacle)checkSelf(l);
        bool v;

        checkType(l, 2, out v);
        o.carving = v;
        return(0);
    }
        private void _getObstacle()
        {
            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (go == null)
            {
                return;
            }

            _obstacle =  go.GetComponent<NavMeshObstacle>();
        }
Esempio n. 15
0
 public virtual void Start()
 {
     agent = GetComponent<NavMeshAgent>();
     obstacle = GetComponent<NavMeshObstacle>();
     obstacle.enabled = false;
     animator = GetComponent<Animator>();
     aggroRadius = GetComponentInChildren<AggroRadius>();
     InitStat();
     InitEventMessenger();
 }
 void Awake()
 {
     player = GameObject.Find("Player");
     playerHealth = player.GetComponent <PlayerHealth>();
     enemyHealth = GetComponent <EnemyHealth>();
     nav = GetComponent <NavMeshAgent>();
     obstacle = GetComponent<NavMeshObstacle>();
     navEnabled = true;
     animator = GetComponent<Animator>();
     characterController = GetComponent<CharacterController>();
 }
Esempio n. 17
0
 static public int get_velocity(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.velocity);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_shape(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         pushEnum(l, (int)self.shape);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Esempio n. 19
0
 static public int get_shape(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.shape);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.NavMeshObstacle o;
			o=new UnityEngine.NavMeshObstacle();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
    // Use this for initialization
    void Start()
    {
        agent = GetComponent<NavMeshAgent> ();
        obstacle = GetComponent<NavMeshObstacle> ();

        AgentToObstacle ();

        mat = GetComponent<Renderer>().material;
        mat.SetColor("_Color", Color.magenta);

        //agent.SetDestination(new Vector3(20, 1, 20));
    }
Esempio n. 22
0
 static public int get_carvingMoveThreshold(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.carvingMoveThreshold);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_velocity(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         pushValue(l, self.velocity);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle o;
         o = new UnityEngine.NavMeshObstacle();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Esempio n. 25
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle o;
         o = new UnityEngine.NavMeshObstacle();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 26
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.NavMeshObstacle o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.NavMeshObstacle();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle o;
         o=new UnityEngine.NavMeshObstacle();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 static public int set_shape(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle      self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         UnityEngine.NavMeshObstacleShape v;
         checkEnum(l, 2, out v);
         self.shape = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Esempio n. 29
0
 static public int set_radius(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.radius = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_radius(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.radius = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Esempio n. 31
0
 static public int set_velocity(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         UnityEngine.Vector3         v;
         checkType(l, 2, out v);
         self.velocity = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_velocity(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         UnityEngine.Vector3         v;
         checkType(l, 2, out v);
         self.velocity = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int set_carveOnlyStationary(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.carveOnlyStationary = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Esempio n. 34
0
 static public int set_carveOnlyStationary(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.carveOnlyStationary = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 35
0
 static public int set_shape(IntPtr l)
 {
     try {
         UnityEngine.NavMeshObstacle      self = (UnityEngine.NavMeshObstacle)checkSelf(l);
         UnityEngine.NavMeshObstacleShape v;
         checkEnum(l, 2, out v);
         self.shape = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 36
0
 static void NavMeshObstacle_velocity(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.NavMeshObstacle _this = (UnityEngine.NavMeshObstacle)vc.csObj;
         var result = _this.velocity;
         JSApi.setVector3S((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Vector3         arg0  = (UnityEngine.Vector3)JSApi.getVector3S((int)JSApi.GetType.Arg);
         UnityEngine.NavMeshObstacle _this = (UnityEngine.NavMeshObstacle)vc.csObj;
         _this.velocity = arg0;
     }
 }
Esempio n. 37
0
 static void NavMeshObstacle_carving(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.NavMeshObstacle _this = (UnityEngine.NavMeshObstacle)vc.csObj;
         var result = _this.carving;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean arg0 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.NavMeshObstacle _this = (UnityEngine.NavMeshObstacle)vc.csObj;
         _this.carving = arg0;
     }
 }
 static void NavMeshObstacle_shape(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.NavMeshObstacle _this = (UnityEngine.NavMeshObstacle)vc.csObj;
         var result = _this.shape;
         JSApi.setEnum((int)JSApi.SetType.Rval, (int)result);
     }
     else
     {
         UnityEngine.NavMeshObstacleShape arg0  = (UnityEngine.NavMeshObstacleShape)JSApi.getEnum((int)JSApi.GetType.Arg);
         UnityEngine.NavMeshObstacle      _this = (UnityEngine.NavMeshObstacle)vc.csObj;
         _this.shape = arg0;
     }
 }
Esempio n. 39
0
 static void NavMeshObstacle_radius(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.NavMeshObstacle _this = (UnityEngine.NavMeshObstacle)vc.csObj;
         var result = _this.radius;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.NavMeshObstacle _this = (UnityEngine.NavMeshObstacle)vc.csObj;
         _this.radius = arg0;
     }
 }
Esempio n. 40
0
	void Start () {
		on = true;

		anim = GetComponent<Animator> ();
		anim.SetBool ("Open", true);

		Vector3 temp = navObjectLocation.position;
		Vector3 newPos = new Vector3(temp.x, temp.z, temp.y);
		navObject.position = newPos;

		navObstacle = navObject.GetComponent<NavMeshObstacle> ();

		// Fix for unity 5.2 network animator
		//for (int i = 0; i < GetComponent<Animator> ().parameterCount; i++)
		//	GetComponent<NetworkAnimator> ().SetParameterAutoSend (i, true);
	}
	public Vector3 nextPointMarker = Vector3.zero; // just for nav debugging
	
	void Awake()
	{
		m_navMeshAgent = GetComponent<NavMeshAgent>();
		m_navMeshObstacle = GetComponent<NavMeshObstacle>();
		if (m_navMeshAgent != null){
			defaultSpeed = m_navMeshAgent.speed;
//			m_navMeshAgent.autoBraking = false; // this seems to hurt a lot more than it helps.
//			m_navMeshAgent.stoppingDistance = 0.1f;
		}
		lastAvoidCheckTime = Time.time;
		//Time.timeScale = 0.25f;
		if (headingTransform == null){
			LookAtController model = GetComponentInChildren(typeof(LookAtController)) as LookAtController;
			if (model != null) headingTransform = model.transform;			
		}
	}
    void Start()
    {
        controller = GetComponent<NavMeshAgent>();
        enemyAnimation = GetComponent<Animator>();
        combatManager = GetComponent<EnemyCombatManager>();
        photonView = GetComponent<PhotonView>();
        obstacle = GetComponent<NavMeshObstacle>();
        controller.avoidancePriority = Random.Range(0, 99);
        
        //player = GameObject.FindGameObjectWithTag("Player");
        initialPosition = transform.position;
        controller.stoppingDistance = chaseStopDistance;

        if(PhotonNetwork.isMasterClient)
        {
            StartCoroutine(Movement());
        }
    }
Esempio n. 43
0
        public Building(Properties a_properties, Mesh a_mesh, Texture2D a_texture)
            : base(a_properties.ID, a_properties.name)
        {
            // Init properties
            m_totalHealth = a_properties.health;
            m_power = a_properties.power;
            m_cost = a_properties.cost;
            m_buildTime = a_properties.buildTime;
            m_miniSize = a_properties.miniSize;
            m_type = Type.DEFAULT;
            m_gameObject.tag = "Building";
            m_gameObject.layer = 10;

            base.Init(a_mesh, a_texture);

            // Nav mesh obstacle
            m_obstacle = m_gameObject.AddComponent<NavMeshObstacle>();
            m_obstacle.radius = m_radius;
            m_obstacle.height = m_mesh.mesh.bounds.size.y;
        }
Esempio n. 44
0
    void Start()
    {
        agent            = proxy.GetComponent< NavMeshAgent >();
        obstacle         = proxy.GetComponent< NavMeshObstacle >();
        //obstacle.enabled = true;

        LOS              = 15.0f;
        damage           = 25.0f;
        reDetect         = 0.5f;
        timeToAttack     = 0.5f;
        mustAttack       = true;
        lifeToBack       = 50;
        life             = 100.0f;
        lifeMax          = life;
        loot             = 75.0f;
        distanceToAttack = 10.0f; // Distance pour un CAC

        rooms            = GameObject.FindGameObjectsWithTag ("RoomTAG");
        target = null;
    }
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        //float moveHorizontal = Input.GetAxis("horizontal");
        //float moveVertical = Input.GetAxis("vertical");

        //Select the agent to move and move
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            //select Agent
            if (Physics.Raycast(ray, out hit, 3000))
            {
                if(hit.transform.CompareTag("capsule"))
                {
                    agent = hit.collider.gameObject.GetComponent<NavMeshAgent>();
                }
                if (agent != null)
                {
                    agent.SetDestination(hit.point);
                }
                if (hit.transform.CompareTag("obstacle"))
                {
                    //print("Obstacle");
                    obstacle = hit.collider.gameObject.GetComponent<NavMeshObstacle>();
                }
                if (obstacle != null)
                {
                    if (Input.GetKeyDown(KeyCode.LeftArrow))
                    {
                        print("Obstacle not null");
                        obstacle.transform.Translate(1, 0, 0);
                        //obstacle.transform.position += new Vector3(1.0f, 0.0f, 0.0f);
                    }
                }
            }

        }
    }
    private void Start()
    {
        m_SpeedId = Animator.StringToHash("Speed");

        LifeManager.AddToSceneObjList(gameObject);
        //Init Components
        m_NavMeshPath = new NavMeshPath();
        m_Animator = this.gameObject.GetComponent<Animator>();
        m_NavObs = this.gameObject.GetComponent<NavMeshObstacle>();
        //if (m_NavObs != null)
        //{
        //    m_NavObs.shape = NavMeshObstacleShape.Capsule;
        //    m_NavObs.radius = .5f;
        //}
        if (m_Animator == null)
        {
            Debuger.LogWarning("Animator Not Found");
        }
        //m_NavAgent = this.gameObject.GetComponentInChildren<NavMeshAgent>();
        //if (m_NavAgent == null)
        //{
        //    Debuger.LogError("NavMeshAgent Not Found");
        //    return;
        //}
        //reset char pos
        NavMeshHit hit;
        if (NavMesh.SamplePosition(this.gameObject.transform.position, out hit, 5.0f, NavMesh.AllAreas))
        {
            this.gameObject.transform.position = hit.position;
        }

        CharSettingScript setting = gameObject.GetComponent<CharSettingScript>();
        if (setting != null)
        {
            m_MaxSpeed = setting.DefaultSpeed;
        }

    }
Esempio n. 47
0
	// Use this for initialization
	void Start () {
        if (e == null)
            e = gameObject.AddComponent<NavMeshObstacle>();
        e.enabled = false;
    }
Esempio n. 48
0
    public IEnumerator nextframe()
    {
        yield return null;

        if (e == null)
            e = gameObject.AddComponent<NavMeshObstacle>();
        e.enabled = true;
        e.carving = true;
        e.size = new Vector3(1, 2, 1);
    }
 void Awake()
 {
     navMeshAgent = GetComponent<NavMeshAgent>();
     navMeshObstacle = GetComponent<NavMeshObstacle>();
 }
Esempio n. 50
0
 // Use this for initialization
 void Start()
 {
     grabbed = false;
     obstacle = GetComponentInChildren<NavMeshObstacle>();
     originalY = this.transform.position.y;
 }
Esempio n. 51
0
    // Use this for initialization
    void Start()
    {
        if(pathManager == null) {
            pathManager = GameObject.Find (vars.path_manager_name).GetComponent<wp_manager>();
        }

        if(baseManager == null) {
            baseManager = GameObject.Find (vars.base_name).GetComponent<base_manager>();
        }

        if(workerManager == null) {
            workerManager = GameObject.Find (vars.worker_manager_name).GetComponent<WorkerManager>();
        }

        workerManager.addWorker(this);
        navMeshAgent = GetComponent<NavMeshAgent>();
        navMeshObstacle = GetComponent<NavMeshObstacle>();
    }
        /// <summary>
        /// Initializes all required variables.
        /// </summary>
        protected void InitializeNavAgentBase()
        {
            if(NavAgent == null)
                NavAgent = this.GetComponent<NavMeshAgent>();
            if(NavObstacle == null)
                NavObstacle = this.GetComponent<NavMeshObstacle>();
            if(m_transformComponent == null)
                m_transformComponent = this.GetComponent<Transform>();

            SetPositionOnNavMesh();
        }
 static public int get_radius(IntPtr l)
 {
     UnityEngine.NavMeshObstacle o = (UnityEngine.NavMeshObstacle)checkSelf(l);
     pushValue(l, o.radius);
     return(1);
 }
 static public int get_height(IntPtr l)
 {
     UnityEngine.NavMeshObstacle o = (UnityEngine.NavMeshObstacle)checkSelf(l);
     pushValue(l, o.height);
     return(1);
 }
 static public int get_velocity(IntPtr l)
 {
     UnityEngine.NavMeshObstacle o = (UnityEngine.NavMeshObstacle)checkSelf(l);
     pushValue(l, o.velocity);
     return(1);
 }
 static public int get_carvingMoveThreshold(IntPtr l)
 {
     UnityEngine.NavMeshObstacle o = (UnityEngine.NavMeshObstacle)checkSelf(l);
     pushValue(l, o.carvingMoveThreshold);
     return(1);
 }
 // Use this for initialization
 void Start()
 {
     agent = null; //GetComponent<NavMeshAgent>();
     obstacle = null;
     anim = null;
 }
Esempio n. 58
0
 void Start()
 {
     gate = GetComponent<NavMeshObstacle>();
     GetComponent<NavMeshObstacle>().carving = true;
 }
    // Use this for initialization
    void Start()
    {
        var player = GameObject.FindGameObjectWithTag("Player");
        target_position = player.transform.position;
        target_direction = Vector3.Normalize(target_position - transform.position);

        navmesh = GetComponent<NavMeshObstacle>();
        collider = GetComponent<Collider>();

        navmesh.enabled = false;
        collider.enabled = false;
    }