Quantcast
Channel: Questions in topic: "unassiunassignedreferenceexception"
Viewing all articles
Browse latest Browse all 30

Cant get rid of log spam UnassignedReferenceException.

$
0
0
This code does what i want in game. But the log is spammed with UnassignedReferenceException for target. I have no idea why. I tried searching and reading to learn what is wrong but cant figure it out. Can someone please take a look? using UnityEngine; using System.Collections; public class WarriorController : MonoBehaviour { public GameObject goal; NavMeshAgent agent; public GameObject target; public bool stopNavigation = false; // Use this for initialization void Start () { goal = GameObject.Find ("Waypoint"); } // Update is called once per frame void Update () { if (target) { transform.GetComponent ().Stop (); } if (stopNavigation == false) { NavMeshAgent agent = GetComponent (); agent.destination = goal.transform.position; } if (Vector3.Distance (target.transform.position, this.transform.position) < 10) { Vector3 direction = target.transform.position - this.transform.position; this.transform.rotation = Quaternion.Slerp (this.transform.rotation, Quaternion.LookRotation (direction), 0.1f); } } void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "team2") { //this.transform.LookAt(other.gameObject.transform); stopNavigation = true; target = other.gameObject; } } }

Viewing all articles
Browse latest Browse all 30

Trending Articles



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