- Home /
 
               Question by 
               jaguilar0047 · May 21, 2018 at 05:49 PM · 
                scripting problemaiscore  
              
 
              Plz Help, Score/Kill counter and Enemy Movement
So i am making a game but my Enemies will not follow my Player once i create a Prefab and insert them in my Timed Spawner code. I have no idea how to fix this and i can't find any tutorials that will work. My starting out Enemies work and follow my avatar but the Spawner ones don't, and i would like to create a C# script that will affect my UI to move up one point per kill. If someone can help me solve these problems plz help using System.Collections; using System.Collections.Generic; using UnityEngine;
public class TimedSpawn : MonoBehaviour {
 //public GameObject spawnee;
 //  public bool stopSpawning;
 // public float spawnTime;
 //   public float spawnDelay;
 // void Start()
 //  {
 //      InvokeRepeating("SpawnObject", spawnTime, spawnDelay);
 //  }
 //  public void SpawnObject()
 // {
 //     Instantiate(spawnee, transform.position, transform.rotation);
 //    if (stopSpawning)
 //   {
 //  CancelInvoke("SpawnObject");
 // }
 //   }
 public GameObject spawnee;
 public Transform player;
 public bool stopSpawning;
 public float spawnTime;
 public float spawnDelay;
 void Start()
 {
     InvokeRepeating("SpawnObject", spawnTime, spawnDelay);
 }
 public void SpawnObject()
 {
     var newObject = Instantiate(spawnee, transform.position, transform.rotation);
     var newObjectMove = newObject.GetComponent<NPCMove>();
     newObjectMove.destination = player;
     if (stopSpawning)
     {
         CancelInvoke("SpawnObject");
     }
 }
}
               Comment
              
 
               
              This is my Enemy movement Scrpit
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI;
public class NPC$$anonymous$$ove : $$anonymous$$onoBehaviour {
 [SerializeField]
 Transform _destination;
 Nav$$anonymous$$eshAgent _nav$$anonymous$$eshAgent;
 internal Transform destination;
 // Use this for initialization
 void Start()
 {
     _nav$$anonymous$$eshAgent = this.GetComponent<Nav$$anonymous$$eshAgent>();
     if (_nav$$anonymous$$eshAgent == null)
     {
         Debug.LogError("The nav mesh agent component is not attached to " + gameObject.name);
     }
     else
     {
         SetDestination();
     }
 }
 public void SetDestination()
 {
     if(_destination != null)
     {
         Vector3 targetVector = _destination.transform.position;
         _nav$$anonymous$$eshAgent.SetDestination(targetVector);
     }
 }
 public void Update()
 {
     SetDestination();
 }
}
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                