Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

SetDestination function error

$
0
0
Hi, I was creating game by this tutorial: https://www.youtube.com/watch?v=xUl-Agx2cLc and I got stucked when script from them doesn't work as it should. I get error "SetDestination" can only be called on an active agent that has been placed on a NavMesh. " with this script: Here is whole code (most of functions are disables until I make these things (as in tutorial where I'm learning from)): using UnityEngine; using System.Collections; public class EnemyMovement : MonoBehaviour { Transform player; //PlayerHealth playerHealth; //EnemyHealth enemyHealth; NavMeshAgent nav; void Awake () { player = GameObject.FindGameObjectWithTag ("MyPlayer").transform; //playerHealth = player.GetComponent (); //enemyHealth = GetComponent (); nav = GetComponent (); } void Update () { //if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0) //{ nav.SetDestination(player.position); //} //else //{ // nav.enabled = false; //} } } I hope someone has an idea how to fix it because my enemy doesn't move there where I am but just enemy keeps his position all the time.

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>